communicator/ssh, builder/digitalocean: fix new SSH API from upstream
This commit is contained in:
parent
aee1916751
commit
eaba28a370
|
@ -38,8 +38,8 @@ func (s *stepCreateSSHKey) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
state.Put("privateKey", string(pem.EncodeToMemory(&priv_blk)))
|
state.Put("privateKey", string(pem.EncodeToMemory(&priv_blk)))
|
||||||
|
|
||||||
// Marshal the public key into SSH compatible format
|
// Marshal the public key into SSH compatible format
|
||||||
pub := priv.PublicKey
|
pub := ssh.NewRSAPublicKey(&priv.PublicKey)
|
||||||
pub_sshformat := string(ssh.MarshalAuthorizedKey(&pub))
|
pub_sshformat := string(ssh.MarshalAuthorizedKey(pub))
|
||||||
|
|
||||||
// The name of the public key on DO
|
// The name of the public key on DO
|
||||||
name := fmt.Sprintf("packer-%s", hex.EncodeToString(identifier.NewUUID().Raw()))
|
name := fmt.Sprintf("packer-%s", hex.EncodeToString(identifier.NewUUID().Raw()))
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"errors"
|
"errors"
|
||||||
|
"code.google.com/p/go.crypto/ssh"
|
||||||
"io"
|
"io"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -53,15 +54,15 @@ func (k *SimpleKeychain) AddPEMKeyPassword(key string, password string) (err err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Key method for ssh.ClientKeyring interface
|
// Key method for ssh.ClientKeyring interface
|
||||||
func (k *SimpleKeychain) Key(i int) (interface{}, error) {
|
func (k *SimpleKeychain) Key(i int) (ssh.PublicKey, error) {
|
||||||
if i < 0 || i >= len(k.keys) {
|
if i < 0 || i >= len(k.keys) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
switch key := k.keys[i].(type) {
|
switch key := k.keys[i].(type) {
|
||||||
case *rsa.PrivateKey:
|
case *rsa.PrivateKey:
|
||||||
return &key.PublicKey, nil
|
return ssh.NewRSAPublicKey(&key.PublicKey), nil
|
||||||
case *dsa.PrivateKey:
|
case *dsa.PrivateKey:
|
||||||
return &key.PublicKey, nil
|
return ssh.NewDSAPublicKey(&key.PublicKey), nil
|
||||||
}
|
}
|
||||||
panic("unknown key type")
|
panic("unknown key type")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue