builder/azure-arm: Fix SSH connection for temporary admin users specified in `ssh_username` (#9103)

pull/9111/head
Wilken Rivera 6 years ago committed by GitHub
parent 26d768f429
commit e0d2f4fd69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -675,27 +675,40 @@ func setRuntimeValues(c *Config) {
}
func setUserNamePassword(c *Config) error {
// Set default credentials generated by the builder
c.UserName = DefaultUserName
c.Password = c.tmpAdminPassword
// Set communicator specific credentials and update defaults if different.
// Communicator specific credentials need to be updated as the standard Packer
// SSHConfigFunc and WinRMConfigFunc use communicator specific credentials, unless overwritten.
// SSH comm
if c.Comm.SSHUsername == "" {
c.Comm.SSHUsername = DefaultUserName
c.Comm.SSHUsername = c.UserName
}
c.UserName = c.Comm.SSHUsername
if c.Comm.SSHPassword != "" {
c.Password = c.Comm.SSHPassword
if c.Comm.SSHPassword == "" {
c.Comm.SSHPassword = c.Password
}
c.Password = c.Comm.SSHPassword
if c.Comm.Type == "ssh" {
return nil
}
// WinRM comm
if c.Comm.WinRMUser == "" {
c.Comm.WinRMUser = DefaultUserName
c.Comm.WinRMUser = c.UserName
}
c.UserName = c.Comm.WinRMUser
if c.Comm.WinRMPassword == "" {
// Configure password settings using Azure generated credentials
c.Comm.WinRMPassword = c.tmpAdminPassword
c.Comm.WinRMPassword = c.Password
}
if !isValidPassword(c.Comm.WinRMPassword) {
return fmt.Errorf("The supplied \"winrm_password\" must be between 8-123 characters long and must satisfy at least 3 from the following: \n1) Contains an uppercase character \n2) Contains a lowercase character\n3) Contains a numeric digit\n4) Contains a special character\n5) Control characters are not allowed")
}

Loading…
Cancel
Save