allow user to override vagrant authentication by setting ssh_username and ssh_password.

This commit is contained in:
Megan Marsh 2019-06-21 16:27:34 -07:00
parent 757bd4bed9
commit 06a0db9350
1 changed files with 8 additions and 2 deletions

View File

@ -36,8 +36,6 @@ func (s *StepSSHConfig) Run(ctx context.Context, state multistep.StateBag) multi
return multistep.ActionHalt
}
config.Comm.SSHPrivateKeyFile = sshConfig.IdentityFile
config.Comm.SSHUsername = sshConfig.User
config.Comm.SSHHost = sshConfig.Hostname
port, err := strconv.Atoi(sshConfig.Port)
if err != nil {
@ -46,6 +44,14 @@ func (s *StepSSHConfig) Run(ctx context.Context, state multistep.StateBag) multi
}
config.Comm.SSHPort = port
if config.Comm.SSHUsername != "" {
// If user has set the username within the communicator, use the
// auth provided there.
return multistep.ActionContinue
}
config.Comm.SSHPrivateKeyFile = sshConfig.IdentityFile
config.Comm.SSHUsername = sshConfig.User
return multistep.ActionContinue
}