Merge pull request #6238 from DanHam/fix-scaleway-auto-ssh-key

Fix use of automatically generated ssh key for Scaleway
pull/6105/head
Rickard von Essen 8 years ago committed by GitHub
commit 4be5f072c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -18,7 +18,6 @@ func commHost(state multistep.StateBag) (string, error) {
func sshConfig(state multistep.StateBag) (*ssh.ClientConfig, error) { func sshConfig(state multistep.StateBag) (*ssh.ClientConfig, error) {
config := state.Get("config").(Config) config := state.Get("config").(Config)
var privateKey string
var auth []ssh.AuthMethod var auth []ssh.AuthMethod
@ -45,11 +44,9 @@ func sshConfig(state multistep.StateBag) (*ssh.ClientConfig, error) {
) )
} }
if config.Comm.SSHPrivateKey != "" { // Use key based auth if there is a private key in the state bag
if priv, ok := state.GetOk("privateKey"); ok { if privateKey, ok := state.GetOk("private_key"); ok {
privateKey = priv.(string) signer, err := ssh.ParsePrivateKey([]byte(privateKey.(string)))
}
signer, err := ssh.ParsePrivateKey([]byte(privateKey))
if err != nil { if err != nil {
return nil, fmt.Errorf("Error setting up SSH config: %s", err) return nil, fmt.Errorf("Error setting up SSH config: %s", err)
} }

@ -36,7 +36,7 @@ func (s *stepCreateSSHKey) Run(_ context.Context, state multistep.StateBag) mult
return multistep.ActionHalt return multistep.ActionHalt
} }
state.Put("privateKey", string(privateKeyBytes)) state.Put("private_key", string(privateKeyBytes))
state.Put("ssh_pubkey", "") state.Put("ssh_pubkey", "")
return multistep.ActionContinue return multistep.ActionContinue
@ -61,7 +61,7 @@ func (s *stepCreateSSHKey) Run(_ context.Context, state multistep.StateBag) mult
} }
// Set the private key in the statebag for later // Set the private key in the statebag for later
state.Put("privateKey", string(pem.EncodeToMemory(&priv_blk))) state.Put("private_key", string(pem.EncodeToMemory(&priv_blk)))
pub, _ := ssh.NewPublicKey(&priv.PublicKey) pub, _ := ssh.NewPublicKey(&priv.PublicKey)
pub_sshformat := string(ssh.MarshalAuthorizedKey(pub)) pub_sshformat := string(ssh.MarshalAuthorizedKey(pub))

Loading…
Cancel
Save