Merge pull request #2912 from esemplare/esxi_ssh_key_support
Add support for SSH Key Authentication with ESX builder
This commit is contained in:
commit
61aea5f123
|
@ -57,6 +57,7 @@ type Config struct {
|
||||||
RemotePort uint `mapstructure:"remote_port"`
|
RemotePort uint `mapstructure:"remote_port"`
|
||||||
RemoteUser string `mapstructure:"remote_username"`
|
RemoteUser string `mapstructure:"remote_username"`
|
||||||
RemotePassword string `mapstructure:"remote_password"`
|
RemotePassword string `mapstructure:"remote_password"`
|
||||||
|
RemotePrivateKey string `mapstructure:"remote_private_key_file"`
|
||||||
|
|
||||||
ctx interpolate.Context
|
ctx interpolate.Context
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ func NewDriver(config *Config) (vmwcommon.Driver, error) {
|
||||||
Port: config.RemotePort,
|
Port: config.RemotePort,
|
||||||
Username: config.RemoteUser,
|
Username: config.RemoteUser,
|
||||||
Password: config.RemotePassword,
|
Password: config.RemotePassword,
|
||||||
|
PrivateKey: config.RemotePrivateKey,
|
||||||
Datastore: config.RemoteDatastore,
|
Datastore: config.RemoteDatastore,
|
||||||
CacheDatastore: config.RemoteCacheDatastore,
|
CacheDatastore: config.RemoteCacheDatastore,
|
||||||
CacheDirectory: config.RemoteCacheDirectory,
|
CacheDirectory: config.RemoteCacheDirectory,
|
||||||
|
|
|
@ -15,6 +15,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/mitchellh/multistep"
|
"github.com/mitchellh/multistep"
|
||||||
|
commonssh "github.com/mitchellh/packer/common/ssh"
|
||||||
"github.com/mitchellh/packer/communicator/ssh"
|
"github.com/mitchellh/packer/communicator/ssh"
|
||||||
"github.com/mitchellh/packer/packer"
|
"github.com/mitchellh/packer/packer"
|
||||||
gossh "golang.org/x/crypto/ssh"
|
gossh "golang.org/x/crypto/ssh"
|
||||||
|
@ -27,6 +28,7 @@ type ESX5Driver struct {
|
||||||
Port uint
|
Port uint
|
||||||
Username string
|
Username string
|
||||||
Password string
|
Password string
|
||||||
|
PrivateKey string
|
||||||
Datastore string
|
Datastore string
|
||||||
CacheDatastore string
|
CacheDatastore string
|
||||||
CacheDirectory string
|
CacheDirectory string
|
||||||
|
@ -340,7 +342,15 @@ func (d *ESX5Driver) connect() error {
|
||||||
ssh.PasswordKeyboardInteractive(d.Password)),
|
ssh.PasswordKeyboardInteractive(d.Password)),
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(dougm) KeyPath support
|
if d.PrivateKey != "" {
|
||||||
|
signer, err := commonssh.FileSigner(d.PrivateKey)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
auth = append(auth, gossh.PublicKeys(signer))
|
||||||
|
}
|
||||||
|
|
||||||
sshConfig := &ssh.Config{
|
sshConfig := &ssh.Config{
|
||||||
Connection: ssh.ConnectFunc("tcp", address),
|
Connection: ssh.ConnectFunc("tcp", address),
|
||||||
SSHConfig: &gossh.ClientConfig{
|
SSHConfig: &gossh.ClientConfig{
|
||||||
|
|
|
@ -187,6 +187,10 @@ builder.
|
||||||
the remote machine. By default this is empty. This only has an effect if
|
the remote machine. By default this is empty. This only has an effect if
|
||||||
`remote_type` is enabled.
|
`remote_type` is enabled.
|
||||||
|
|
||||||
|
- `remote_private_key_file` (string) - The path to the PEM encoded private key
|
||||||
|
file for the user used to access the remote machine. By default this is empty.
|
||||||
|
This only has an effect if `remote_type` is enabled.
|
||||||
|
|
||||||
- `remote_type` (string) - The type of remote machine that will be used to
|
- `remote_type` (string) - The type of remote machine that will be used to
|
||||||
build this VM rather than a local desktop product. The only value accepted
|
build this VM rather than a local desktop product. The only value accepted
|
||||||
for this currently is "esx5". If this is not set, a desktop product will
|
for this currently is "esx5". If this is not set, a desktop product will
|
||||||
|
@ -398,6 +402,8 @@ modify as well:
|
||||||
|
|
||||||
- `remote_password` - The SSH password for access to the remote machine.
|
- `remote_password` - The SSH password for access to the remote machine.
|
||||||
|
|
||||||
|
- `remote_private_key_file` - The SSH key for access to the remote machine.
|
||||||
|
|
||||||
- `format` (string) - Either "ovf", "ova" or "vmx", this specifies the output
|
- `format` (string) - Either "ovf", "ova" or "vmx", this specifies the output
|
||||||
format of the exported virtual machine. This defaults to "ovf".
|
format of the exported virtual machine. This defaults to "ovf".
|
||||||
Before using this option, you need to install `ovftool`.
|
Before using this option, you need to install `ovftool`.
|
||||||
|
|
Loading…
Reference in New Issue