diff --git a/builder/vmware/iso/driver_esx5.go b/builder/vmware/iso/driver_esx5.go index 9b489ac6b..48f265bbf 100644 --- a/builder/vmware/iso/driver_esx5.go +++ b/builder/vmware/iso/driver_esx5.go @@ -17,6 +17,7 @@ import ( vmwcommon "github.com/hashicorp/packer/builder/vmware/common" "github.com/hashicorp/packer/communicator/ssh" "github.com/hashicorp/packer/helper/multistep" + helperssh "github.com/hashicorp/packer/helper/ssh" "github.com/hashicorp/packer/packer" gossh "golang.org/x/crypto/ssh" ) @@ -514,7 +515,7 @@ func (d *ESX5Driver) connect() error { } if d.PrivateKey != "" { - signer, err := gossh.ParsePrivateKey([]byte(d.PrivateKey)) + signer, err := helperssh.FileSigner(d.PrivateKey) if err != nil { return err } diff --git a/helper/communicator/config.go b/helper/communicator/config.go index fa208092d..990e915f2 100644 --- a/helper/communicator/config.go +++ b/helper/communicator/config.go @@ -10,6 +10,7 @@ import ( packerssh "github.com/hashicorp/packer/communicator/ssh" "github.com/hashicorp/packer/helper/multistep" + helperssh "github.com/hashicorp/packer/helper/ssh" "github.com/hashicorp/packer/template/interpolate" "github.com/masterzen/winrm" "golang.org/x/crypto/ssh" @@ -241,7 +242,7 @@ func (c *Config) prepareSSH(ctx *interpolate.Context) []error { if _, err := os.Stat(c.SSHPrivateKeyFile); err != nil { errs = append(errs, fmt.Errorf( "ssh_private_key_file is invalid: %s", err)) - } else if _, err := SSHFileSigner(c.SSHPrivateKeyFile); err != nil { + } else if _, err := helperssh.FileSigner(c.SSHPrivateKeyFile); err != nil { errs = append(errs, fmt.Errorf( "ssh_private_key_file is invalid: %s", err)) } diff --git a/helper/communicator/step_connect_ssh.go b/helper/communicator/step_connect_ssh.go index 7387d0ddf..c0c2935e7 100644 --- a/helper/communicator/step_connect_ssh.go +++ b/helper/communicator/step_connect_ssh.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/packer/communicator/ssh" "github.com/hashicorp/packer/helper/multistep" + helperssh "github.com/hashicorp/packer/helper/ssh" "github.com/hashicorp/packer/packer" gossh "golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh/agent" @@ -225,7 +226,7 @@ func sshBastionConfig(config *Config) (*gossh.ClientConfig, error) { } if config.SSHBastionPrivateKey != "" { - signer, err := gossh.ParsePrivateKey([]byte(config.SSHBastionPrivateKey)) + signer, err := helperssh.FileSigner(config.SSHBastionPrivateKey) if err != nil { return nil, err } diff --git a/helper/communicator/ssh.go b/helper/ssh/ssh.go similarity index 86% rename from helper/communicator/ssh.go rename to helper/ssh/ssh.go index 831d620bc..0de73b78c 100644 --- a/helper/communicator/ssh.go +++ b/helper/ssh/ssh.go @@ -1,4 +1,4 @@ -package communicator +package ssh import ( "encoding/pem" @@ -9,8 +9,8 @@ import ( "golang.org/x/crypto/ssh" ) -// SSHFileSigner returns an ssh.Signer for a key file. -func SSHFileSigner(path string) (ssh.Signer, error) { +// FileSigner returns an ssh.Signer for a key file. +func FileSigner(path string) (ssh.Signer, error) { f, err := os.Open(path) if err != nil { return nil, err