github.com/StackPointCloud/packer@v0.10.2-0.20180716202532-b28098e0f79b/builder/ncloud/ssh.go (about)

     1  package ncloud
     2  
     3  import (
     4  	packerssh "github.com/hashicorp/packer/communicator/ssh"
     5  	"github.com/hashicorp/packer/helper/multistep"
     6  	"golang.org/x/crypto/ssh"
     7  )
     8  
     9  // SSHConfig returns a function that can be used for the SSH communicator
    10  // config for connecting to the specified host via SSH
    11  func SSHConfig(username string) func(multistep.StateBag) (*ssh.ClientConfig, error) {
    12  	return func(state multistep.StateBag) (*ssh.ClientConfig, error) {
    13  		password := state.Get("Password").(string)
    14  
    15  		return &ssh.ClientConfig{
    16  			User: username,
    17  			Auth: []ssh.AuthMethod{
    18  				ssh.Password(password),
    19  				ssh.KeyboardInteractive(
    20  					packerssh.PasswordKeyboardInteractive(password)),
    21  			},
    22  			HostKeyCallback: ssh.InsecureIgnoreHostKey(),
    23  		}, nil
    24  	}
    25  }