From eaba28a3704b71f98ea1ff676233c64f216aa92e Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 15 Sep 2013 12:21:21 -0700 Subject: [PATCH] communicator/ssh, builder/digitalocean: fix new SSH API from upstream --- builder/digitalocean/step_create_ssh_key.go | 4 ++-- communicator/ssh/keychain.go | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/builder/digitalocean/step_create_ssh_key.go b/builder/digitalocean/step_create_ssh_key.go index f33a368e8..6a9f0426c 100644 --- a/builder/digitalocean/step_create_ssh_key.go +++ b/builder/digitalocean/step_create_ssh_key.go @@ -38,8 +38,8 @@ func (s *stepCreateSSHKey) Run(state multistep.StateBag) multistep.StepAction { state.Put("privateKey", string(pem.EncodeToMemory(&priv_blk))) // Marshal the public key into SSH compatible format - pub := priv.PublicKey - pub_sshformat := string(ssh.MarshalAuthorizedKey(&pub)) + pub := ssh.NewRSAPublicKey(&priv.PublicKey) + pub_sshformat := string(ssh.MarshalAuthorizedKey(pub)) // The name of the public key on DO name := fmt.Sprintf("packer-%s", hex.EncodeToString(identifier.NewUUID().Raw())) diff --git a/communicator/ssh/keychain.go b/communicator/ssh/keychain.go index 686a6b1cb..39ab8cda0 100644 --- a/communicator/ssh/keychain.go +++ b/communicator/ssh/keychain.go @@ -7,6 +7,7 @@ import ( "crypto/x509" "encoding/pem" "errors" + "code.google.com/p/go.crypto/ssh" "io" ) @@ -53,15 +54,15 @@ func (k *SimpleKeychain) AddPEMKeyPassword(key string, password string) (err err } // 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) { return nil, nil } switch key := k.keys[i].(type) { case *rsa.PrivateKey: - return &key.PublicKey, nil + return ssh.NewRSAPublicKey(&key.PublicKey), nil case *dsa.PrivateKey: - return &key.PublicKey, nil + return ssh.NewDSAPublicKey(&key.PublicKey), nil } panic("unknown key type") }