SSHPrivateKey => SSHPrivateKeyFile
This commit is contained in:
parent
c0b52b0aff
commit
51d2aac9f6
|
@ -98,7 +98,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
&stepConfigAlicloudKeyPair{
|
||||
Debug: b.config.PackerDebug,
|
||||
KeyPairName: b.config.SSHKeyPairName,
|
||||
PrivateKeyFile: b.config.Comm.SSHPrivateKey,
|
||||
PrivateKeyFile: b.config.Comm.SSHPrivateKeyFile,
|
||||
TemporaryKeyPairName: b.config.TemporaryKeyPairName,
|
||||
SSHAgentAuth: b.config.Comm.SSHAgentAuth,
|
||||
DebugKeyPath: fmt.Sprintf("ecs_%s.pem", b.config.PackerBuildName),
|
||||
|
@ -230,7 +230,7 @@ func (b *Builder) isVpcSpecified() bool {
|
|||
|
||||
func (b *Builder) isUserDataNeeded() bool {
|
||||
// Public key setup requires userdata
|
||||
if b.config.RunConfig.Comm.SSHPrivateKey != "" {
|
||||
if b.config.RunConfig.Comm.SSHPrivateKeyFile != "" {
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ type RunConfig struct {
|
|||
|
||||
func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
||||
if c.SSHKeyPairName == "" && c.TemporaryKeyPairName == "" &&
|
||||
c.Comm.SSHPrivateKey == "" && c.Comm.SSHPassword == "" && c.Comm.WinRMPassword == "" {
|
||||
c.Comm.SSHPrivateKeyFile == "" && c.Comm.SSHPassword == "" && c.Comm.WinRMPassword == "" {
|
||||
|
||||
c.TemporaryKeyPairName = fmt.Sprintf("packer_%s", uuid.TimeOrderedUUID())
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
|||
// temporary_key_pair_name has not been provided and we are not using
|
||||
// ssh_password.
|
||||
if c.SSHKeyPairName == "" && c.TemporaryKeyPairName == "" &&
|
||||
c.Comm.SSHPrivateKey == "" && c.Comm.SSHPassword == "" {
|
||||
c.Comm.SSHPrivateKeyFile == "" && c.Comm.SSHPassword == "" {
|
||||
|
||||
c.TemporaryKeyPairName = fmt.Sprintf("packer_%s", uuid.TimeOrderedUUID())
|
||||
}
|
||||
|
@ -94,9 +94,9 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
|||
}
|
||||
|
||||
if c.SSHKeyPairName != "" {
|
||||
if c.Comm.Type == "winrm" && c.Comm.WinRMPassword == "" && c.Comm.SSHPrivateKey == "" {
|
||||
if c.Comm.Type == "winrm" && c.Comm.WinRMPassword == "" && c.Comm.SSHPrivateKeyFile == "" {
|
||||
errs = append(errs, fmt.Errorf("ssh_private_key_file must be provided to retrieve the winrm password when using ssh_keypair_name."))
|
||||
} else if c.Comm.SSHPrivateKey == "" && !c.Comm.SSHAgentAuth {
|
||||
} else if c.Comm.SSHPrivateKeyFile == "" && !c.Comm.SSHAgentAuth {
|
||||
errs = append(errs, fmt.Errorf("ssh_private_key_file must be provided or ssh_agent_auth enabled when ssh_keypair_name is specified."))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
DebugKeyPath: fmt.Sprintf("ec2_%s.pem", b.config.PackerBuildName),
|
||||
KeyPairName: b.config.SSHKeyPairName,
|
||||
TemporaryKeyPairName: b.config.TemporaryKeyPairName,
|
||||
PrivateKeyFile: b.config.RunConfig.Comm.SSHPrivateKey,
|
||||
PrivateKeyFile: b.config.RunConfig.Comm.SSHPrivateKeyFile,
|
||||
},
|
||||
&awscommon.StepSecurityGroup{
|
||||
SecurityGroupIds: b.config.SecurityGroupIds,
|
||||
|
|
|
@ -201,7 +201,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
DebugKeyPath: fmt.Sprintf("ec2_%s.pem", b.config.PackerBuildName),
|
||||
KeyPairName: b.config.SSHKeyPairName,
|
||||
TemporaryKeyPairName: b.config.TemporaryKeyPairName,
|
||||
PrivateKeyFile: b.config.RunConfig.Comm.SSHPrivateKey,
|
||||
PrivateKeyFile: b.config.RunConfig.Comm.SSHPrivateKeyFile,
|
||||
},
|
||||
&awscommon.StepSecurityGroup{
|
||||
SecurityGroupIds: b.config.SecurityGroupIds,
|
||||
|
|
|
@ -176,7 +176,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
DebugKeyPath: fmt.Sprintf("ec2_%s.pem", b.config.PackerBuildName),
|
||||
KeyPairName: b.config.SSHKeyPairName,
|
||||
TemporaryKeyPairName: b.config.TemporaryKeyPairName,
|
||||
PrivateKeyFile: b.config.RunConfig.Comm.SSHPrivateKey,
|
||||
PrivateKeyFile: b.config.RunConfig.Comm.SSHPrivateKeyFile,
|
||||
},
|
||||
&awscommon.StepSecurityGroup{
|
||||
SecurityGroupIds: b.config.SecurityGroupIds,
|
||||
|
|
|
@ -261,7 +261,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
SSHAgentAuth: b.config.Comm.SSHAgentAuth,
|
||||
DebugKeyPath: fmt.Sprintf("ec2_%s.pem", b.config.PackerBuildName),
|
||||
KeyPairName: b.config.SSHKeyPairName,
|
||||
PrivateKeyFile: b.config.RunConfig.Comm.SSHPrivateKey,
|
||||
PrivateKeyFile: b.config.RunConfig.Comm.SSHPrivateKeyFile,
|
||||
TemporaryKeyPairName: b.config.TemporaryKeyPairName,
|
||||
},
|
||||
&awscommon.StepSecurityGroup{
|
||||
|
|
|
@ -314,8 +314,8 @@ func setSshValues(c *Config) error {
|
|||
c.Comm.SSHTimeout = 20 * time.Minute
|
||||
}
|
||||
|
||||
if c.Comm.SSHPrivateKey != "" {
|
||||
privateKeyBytes, err := ioutil.ReadFile(c.Comm.SSHPrivateKey)
|
||||
if c.Comm.SSHPrivateKeyFile != "" {
|
||||
privateKeyBytes, err := ioutil.ReadFile(c.Comm.SSHPrivateKeyFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
Debug: b.config.PackerDebug,
|
||||
DebugKeyPath: fmt.Sprintf("cs_%s.pem", b.config.PackerBuildName),
|
||||
KeyPair: b.config.Keypair,
|
||||
PrivateKeyFile: b.config.Comm.SSHPrivateKey,
|
||||
PrivateKeyFile: b.config.Comm.SSHPrivateKeyFile,
|
||||
SSHAgentAuth: b.config.Comm.SSHAgentAuth,
|
||||
TemporaryKeyPairName: b.config.TemporaryKeypairName,
|
||||
},
|
||||
|
|
|
@ -127,7 +127,7 @@ func NewConfig(raws ...interface{}) (*Config, error) {
|
|||
// then create a temporary one, but only if the temporary_keypair_name has not
|
||||
// been provided.
|
||||
if c.Keypair == "" && c.TemporaryKeypairName == "" &&
|
||||
c.Comm.SSHPrivateKey == "" && c.Comm.SSHPassword == "" {
|
||||
c.Comm.SSHPrivateKeyFile == "" && c.Comm.SSHPassword == "" {
|
||||
c.TemporaryKeypairName = fmt.Sprintf("packer_%s", uuid.TimeOrderedUUID())
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
&StepCreateSSHKey{
|
||||
Debug: b.config.PackerDebug,
|
||||
DebugKeyPath: fmt.Sprintf("gce_%s.pem", b.config.PackerBuildName),
|
||||
PrivateKeyFile: b.config.Comm.SSHPrivateKey,
|
||||
PrivateKeyFile: b.config.Comm.SSHPrivateKeyFile,
|
||||
},
|
||||
&StepCreateInstance{
|
||||
Debug: b.config.PackerDebug,
|
||||
|
|
|
@ -43,14 +43,14 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
|
|||
fmt.Errorf("a Username must be specified, please reference your communicator documentation"))
|
||||
}
|
||||
|
||||
if !c.CommConfig.SSHAgentAuth && c.CommConfig.Password() == "" && c.CommConfig.SSHPrivateKey == "" {
|
||||
if !c.CommConfig.SSHAgentAuth && c.CommConfig.Password() == "" && c.CommConfig.SSHPrivateKeyFile == "" {
|
||||
errs = packer.MultiErrorAppend(errs,
|
||||
fmt.Errorf("one authentication method must be specified, please reference your communicator documentation"))
|
||||
}
|
||||
|
||||
if (c.CommConfig.SSHAgentAuth &&
|
||||
(c.CommConfig.SSHPassword != "" || c.CommConfig.SSHPrivateKey != "")) ||
|
||||
(c.CommConfig.SSHPassword != "" && c.CommConfig.SSHPrivateKey != "") {
|
||||
(c.CommConfig.SSHPassword != "" || c.CommConfig.SSHPrivateKeyFile != "")) ||
|
||||
(c.CommConfig.SSHPassword != "" && c.CommConfig.SSHPrivateKeyFile != "") {
|
||||
errs = packer.MultiErrorAppend(errs,
|
||||
fmt.Errorf("only one of ssh_agent_auth, ssh_password, and ssh_private_key_file must be specified"))
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ func (s *StepCreateSSHKey) Run(_ context.Context, state multistep.StateBag) mult
|
|||
ui := state.Get("ui").(packer.Ui)
|
||||
c := state.Get("config").(*Config)
|
||||
|
||||
if c.Comm.SSHPrivateKey != "" {
|
||||
pemBytes, err := ioutil.ReadFile(c.Comm.SSHPrivateKey)
|
||||
if c.Comm.SSHPrivateKeyFile != "" {
|
||||
pemBytes, err := ioutil.ReadFile(c.Comm.SSHPrivateKeyFile)
|
||||
|
||||
if err != nil {
|
||||
ui.Error(err.Error())
|
||||
|
|
|
@ -84,7 +84,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
DebugKeyPath: fmt.Sprintf("os_%s.pem", b.config.PackerBuildName),
|
||||
KeyPairName: b.config.SSHKeyPairName,
|
||||
TemporaryKeyPairName: b.config.TemporaryKeyPairName,
|
||||
PrivateKeyFile: b.config.RunConfig.Comm.SSHPrivateKey,
|
||||
PrivateKeyFile: b.config.RunConfig.Comm.SSHPrivateKeyFile,
|
||||
SSHAgentAuth: b.config.RunConfig.Comm.SSHAgentAuth,
|
||||
},
|
||||
&StepSourceImageInfo{
|
||||
|
|
|
@ -103,7 +103,7 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
|||
// temporary_key_pair_name has not been provided and we are not using
|
||||
// ssh_password.
|
||||
if c.SSHKeyPairName == "" && c.TemporaryKeyPairName == "" &&
|
||||
c.Comm.SSHPrivateKey == "" && c.Comm.SSHPassword == "" {
|
||||
c.Comm.SSHPrivateKeyFile == "" && c.Comm.SSHPassword == "" {
|
||||
|
||||
c.TemporaryKeyPairName = fmt.Sprintf("packer_%s", uuid.TimeOrderedUUID())
|
||||
}
|
||||
|
@ -116,9 +116,9 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
|||
errs := c.Comm.Prepare(ctx)
|
||||
|
||||
if c.SSHKeyPairName != "" {
|
||||
if c.Comm.Type == "winrm" && c.Comm.WinRMPassword == "" && c.Comm.SSHPrivateKey == "" {
|
||||
if c.Comm.Type == "winrm" && c.Comm.WinRMPassword == "" && c.Comm.SSHPrivateKeyFile == "" {
|
||||
errs = append(errs, errors.New("A ssh_private_key_file must be provided to retrieve the winrm password when using ssh_keypair_name."))
|
||||
} else if c.Comm.SSHPrivateKey == "" && !c.Comm.SSHAgentAuth {
|
||||
} else if c.Comm.SSHPrivateKeyFile == "" && !c.Comm.SSHAgentAuth {
|
||||
errs = append(errs, errors.New("A ssh_private_key_file must be provided or ssh_agent_auth enabled when ssh_keypair_name is specified."))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
&ocommon.StepKeyPair{
|
||||
Debug: b.config.PackerDebug,
|
||||
DebugKeyPath: fmt.Sprintf("oci_classic_%s.pem", b.config.PackerBuildName),
|
||||
PrivateKeyFile: b.config.Comm.SSHPrivateKey,
|
||||
PrivateKeyFile: b.config.Comm.SSHPrivateKeyFile,
|
||||
},
|
||||
&stepCreateIPReservation{},
|
||||
&stepAddKeysToAPI{},
|
||||
|
|
|
@ -54,7 +54,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
&ocommon.StepKeyPair{
|
||||
Debug: b.config.PackerDebug,
|
||||
DebugKeyPath: fmt.Sprintf("oci_%s.pem", b.config.PackerBuildName),
|
||||
PrivateKeyFile: b.config.Comm.SSHPrivateKey,
|
||||
PrivateKeyFile: b.config.Comm.SSHPrivateKeyFile,
|
||||
},
|
||||
&stepCreateInstance{},
|
||||
&stepInstanceInfo{},
|
||||
|
|
|
@ -33,14 +33,14 @@ func TestSSHConfigPrepare_SSHPrivateKey(t *testing.T) {
|
|||
var errs []error
|
||||
|
||||
c = testSSHConfig()
|
||||
c.Comm.SSHPrivateKey = ""
|
||||
c.Comm.SSHPrivateKeyFile = ""
|
||||
errs = c.Prepare(testConfigTemplate(t))
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("should not have error: %#v", errs)
|
||||
}
|
||||
|
||||
c = testSSHConfig()
|
||||
c.Comm.SSHPrivateKey = "/i/dont/exist"
|
||||
c.Comm.SSHPrivateKeyFile = "/i/dont/exist"
|
||||
errs = c.Prepare(testConfigTemplate(t))
|
||||
if len(errs) == 0 {
|
||||
t.Fatal("should have error")
|
||||
|
@ -59,7 +59,7 @@ func TestSSHConfigPrepare_SSHPrivateKey(t *testing.T) {
|
|||
}
|
||||
|
||||
c = testSSHConfig()
|
||||
c.Comm.SSHPrivateKey = tf.Name()
|
||||
c.Comm.SSHPrivateKeyFile = tf.Name()
|
||||
errs = c.Prepare(testConfigTemplate(t))
|
||||
if len(errs) == 0 {
|
||||
t.Fatal("should have error")
|
||||
|
@ -70,7 +70,7 @@ func TestSSHConfigPrepare_SSHPrivateKey(t *testing.T) {
|
|||
tf.Truncate(0)
|
||||
tf.Write([]byte(testPem))
|
||||
c = testSSHConfig()
|
||||
c.Comm.SSHPrivateKey = tf.Name()
|
||||
c.Comm.SSHPrivateKeyFile = tf.Name()
|
||||
errs = c.Prepare(testConfigTemplate(t))
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("should not have error: %#v", errs)
|
||||
|
|
|
@ -53,7 +53,7 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
|
|||
|
||||
var errs *packer.MultiError
|
||||
|
||||
if c.Comm.SSHPassword == "" && c.Comm.SSHPrivateKey == "" {
|
||||
if c.Comm.SSHPassword == "" && c.Comm.SSHPrivateKeyFile == "" {
|
||||
errs = packer.MultiErrorAppend(
|
||||
errs, errors.New("Either ssh private key path or ssh password must be set."))
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@ func (s *StepCreateSSHKey) Run(_ context.Context, state multistep.StateBag) mult
|
|||
ui := state.Get("ui").(packer.Ui)
|
||||
c := state.Get("config").(*Config)
|
||||
|
||||
if c.Comm.SSHPrivateKey != "" {
|
||||
pemBytes, err := ioutil.ReadFile(c.Comm.SSHPrivateKey)
|
||||
if c.Comm.SSHPrivateKeyFile != "" {
|
||||
pemBytes, err := ioutil.ReadFile(c.Comm.SSHPrivateKeyFile)
|
||||
|
||||
if err != nil {
|
||||
ui.Error(err.Error())
|
||||
|
|
|
@ -51,7 +51,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
&stepCreateSSHKey{
|
||||
Debug: b.config.PackerDebug,
|
||||
DebugKeyPath: fmt.Sprintf("scw_%s.pem", b.config.PackerBuildName),
|
||||
PrivateKeyFile: b.config.Comm.SSHPrivateKey,
|
||||
PrivateKeyFile: b.config.Comm.SSHPrivateKeyFile,
|
||||
},
|
||||
new(stepCreateServer),
|
||||
new(stepServerInfo),
|
||||
|
|
|
@ -38,7 +38,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
|
|||
|
||||
// If we are using an SSH agent to sign requests, and no private key has been
|
||||
// specified for SSH, use the agent for connecting for provisioning.
|
||||
if b.config.AccessConfig.KeyMaterial == "" && b.config.Comm.SSHPrivateKey == "" {
|
||||
if b.config.AccessConfig.KeyMaterial == "" && b.config.Comm.SSHPrivateKeyFile == "" {
|
||||
b.config.Comm.SSHAgentAuth = true
|
||||
}
|
||||
|
||||
|
|
|
@ -64,14 +64,14 @@ func TestSSHConfigPrepare_SSHPrivateKey(t *testing.T) {
|
|||
var errs []error
|
||||
|
||||
c = testSSHConfig()
|
||||
c.Comm.SSHPrivateKey = ""
|
||||
c.Comm.SSHPrivateKeyFile = ""
|
||||
errs = c.Prepare(testConfigTemplate(t))
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("should not have error: %#v", errs)
|
||||
}
|
||||
|
||||
c = testSSHConfig()
|
||||
c.Comm.SSHPrivateKey = "/i/dont/exist"
|
||||
c.Comm.SSHPrivateKeyFile = "/i/dont/exist"
|
||||
errs = c.Prepare(testConfigTemplate(t))
|
||||
if len(errs) == 0 {
|
||||
t.Fatal("should have error")
|
||||
|
@ -90,7 +90,7 @@ func TestSSHConfigPrepare_SSHPrivateKey(t *testing.T) {
|
|||
}
|
||||
|
||||
c = testSSHConfig()
|
||||
c.Comm.SSHPrivateKey = tf.Name()
|
||||
c.Comm.SSHPrivateKeyFile = tf.Name()
|
||||
errs = c.Prepare(testConfigTemplate(t))
|
||||
if len(errs) == 0 {
|
||||
t.Fatal("should have error")
|
||||
|
@ -101,7 +101,7 @@ func TestSSHConfigPrepare_SSHPrivateKey(t *testing.T) {
|
|||
tf.Truncate(0)
|
||||
tf.Write([]byte(testPem))
|
||||
c = testSSHConfig()
|
||||
c.Comm.SSHPrivateKey = tf.Name()
|
||||
c.Comm.SSHPrivateKeyFile = tf.Name()
|
||||
errs = c.Prepare(testConfigTemplate(t))
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("should not have error: %#v", errs)
|
||||
|
|
|
@ -33,14 +33,14 @@ func TestSSHConfigPrepare_SSHPrivateKey(t *testing.T) {
|
|||
var errs []error
|
||||
|
||||
c = testSSHConfig()
|
||||
c.Comm.SSHPrivateKey = ""
|
||||
c.Comm.SSHPrivateKeyFile = ""
|
||||
errs = c.Prepare(testConfigTemplate(t))
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("should not have error: %#v", errs)
|
||||
}
|
||||
|
||||
c = testSSHConfig()
|
||||
c.Comm.SSHPrivateKey = "/i/dont/exist"
|
||||
c.Comm.SSHPrivateKeyFile = "/i/dont/exist"
|
||||
errs = c.Prepare(testConfigTemplate(t))
|
||||
if len(errs) == 0 {
|
||||
t.Fatal("should have error")
|
||||
|
@ -59,7 +59,7 @@ func TestSSHConfigPrepare_SSHPrivateKey(t *testing.T) {
|
|||
}
|
||||
|
||||
c = testSSHConfig()
|
||||
c.Comm.SSHPrivateKey = tf.Name()
|
||||
c.Comm.SSHPrivateKeyFile = tf.Name()
|
||||
errs = c.Prepare(testConfigTemplate(t))
|
||||
if len(errs) == 0 {
|
||||
t.Fatal("should have error")
|
||||
|
@ -70,7 +70,7 @@ func TestSSHConfigPrepare_SSHPrivateKey(t *testing.T) {
|
|||
tf.Truncate(0)
|
||||
tf.Write([]byte(testPem))
|
||||
c = testSSHConfig()
|
||||
c.Comm.SSHPrivateKey = tf.Name()
|
||||
c.Comm.SSHPrivateKeyFile = tf.Name()
|
||||
errs = c.Prepare(testConfigTemplate(t))
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("should not have error: %#v", errs)
|
||||
|
|
|
@ -26,7 +26,7 @@ type Config struct {
|
|||
SSHPort int `mapstructure:"ssh_port"`
|
||||
SSHUsername string `mapstructure:"ssh_username"`
|
||||
SSHPassword string `mapstructure:"ssh_password"`
|
||||
SSHPrivateKey string `mapstructure:"ssh_private_key_file"`
|
||||
SSHPrivateKeyFile string `mapstructure:"ssh_private_key_file"`
|
||||
SSHPty bool `mapstructure:"ssh_pty"`
|
||||
SSHTimeout time.Duration `mapstructure:"ssh_timeout"`
|
||||
SSHAgentAuth bool `mapstructure:"ssh_agent_auth"`
|
||||
|
@ -83,9 +83,9 @@ func (c *Config) SSHConfigFunc() func(multistep.StateBag) (*ssh.ClientConfig, er
|
|||
}
|
||||
|
||||
var privateKeys [][]byte
|
||||
if c.SSHPrivateKey != "" {
|
||||
if c.SSHPrivateKeyFile != "" {
|
||||
// key based auth
|
||||
bytes, err := ioutil.ReadFile(c.SSHPrivateKey)
|
||||
bytes, err := ioutil.ReadFile(c.SSHPrivateKeyFile)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error setting up SSH config: %s", err)
|
||||
}
|
||||
|
@ -219,8 +219,8 @@ func (c *Config) prepareSSH(ctx *interpolate.Context) []error {
|
|||
c.SSHBastionPort = 22
|
||||
}
|
||||
|
||||
if c.SSHBastionPrivateKey == "" && c.SSHPrivateKey != "" {
|
||||
c.SSHBastionPrivateKey = c.SSHPrivateKey
|
||||
if c.SSHBastionPrivateKey == "" && c.SSHPrivateKeyFile != "" {
|
||||
c.SSHBastionPrivateKey = c.SSHPrivateKeyFile
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -240,11 +240,11 @@ func (c *Config) prepareSSH(ctx *interpolate.Context) []error {
|
|||
errs = append(errs, errors.New("An ssh_username must be specified\n Note: some builders used to default ssh_username to \"root\"."))
|
||||
}
|
||||
|
||||
if c.SSHPrivateKey != "" {
|
||||
if _, err := os.Stat(c.SSHPrivateKey); err != nil {
|
||||
if c.SSHPrivateKeyFile != "" {
|
||||
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.SSHPrivateKey); err != nil {
|
||||
} else if _, err := SSHFileSigner(c.SSHPrivateKeyFile); err != nil {
|
||||
errs = append(errs, fmt.Errorf(
|
||||
"ssh_private_key_file is invalid: %s", err))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue