Merge pull request #7782 from hashicorp/fix_7758
Allow user to override vagrant ssh-config details
This commit is contained in:
commit
bed0938b6c
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -151,3 +151,19 @@ Sample for `hashicorp/precise64` with virtualbox provider.
|
|||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## A note on SSH connections
|
||||
|
||||
Currently this builder only works for SSH connections, and automatically fills
|
||||
in all information needed for the ssh communicator using vagrant's ssh-config.
|
||||
|
||||
If you would like to connect via a different username or authentication method
|
||||
than is produced when you call `vagrant ssh-config`, then you must provide the
|
||||
|
||||
`ssh_username` and all other relevant authentication information (e.g.
|
||||
`ssh_password` or `ssh_private_key_file`)
|
||||
|
||||
By providing the `ssh_username`, you're telling Packer not to use the vagrant
|
||||
ssh config, except for determining the host and port for the virtual machine to
|
||||
connect to.
|
Loading…
Reference in New Issue