Documentation ¶
Index ¶
Constants ¶
const ( // DefaultUser is used if there is no default user given DefaultUser = "root" // DefaultPort is used if there is no port given DefaultPort = 22 // DefaultScriptPath is used as the path to copy the file to // for remote execution if not provided otherwise. DefaultScriptPath = "/tmp/script.sh" // DefaultTimeout is used if there is no timeout given DefaultTimeout = 5 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func ConnectFunc ¶
ConnectFunc is a convenience method for returning a function that just uses net.Dial to communicate with the remote end that is suitable for use with the SSH communicator configuration.
func PasswordKeyboardInteractive ¶
func PasswordKeyboardInteractive(password string) ssh.KeyboardInteractiveChallenge
An implementation of ssh.KeyboardInteractiveChallenge that simply sends back the password for all questions. The questions are logged.
func VerifySSH ¶
func VerifySSH(s *terraform.ResourceState) error
verifySSH is used to verify the ConnInfo is usable by remote-exec
Types ¶
type Config ¶
type Config struct { // The configuration of the Go SSH connection SSHConfig *ssh.ClientConfig // Connection returns a new connection. The current connection // in use will be closed as part of the Close method, or in the // case an error occurs. Connection func() (net.Conn, error) // NoPty, if true, will not request a pty from the remote end. NoPty bool }
Config is the structure used to configure the SSH communicator.
func PrepareConfig ¶
PrepareConfig is used to turn the *SSHConfig provided into a usable *Config for client initialization.
type RemoteCmd ¶
type RemoteCmd struct { // Command is the command to run remotely. This is executed as if // it were a shell command, so you are expected to do any shell escaping // necessary. Command string // Stdin specifies the process's standard input. If Stdin is // nil, the process reads from an empty bytes.Buffer. Stdin io.Reader // Stdout and Stderr represent the process's standard output and // error. // // If either is nil, it will be set to ioutil.Discard. Stdout io.Writer Stderr io.Writer // This will be set to true when the remote command has exited. It // shouldn't be set manually by the user, but there is no harm in // doing so. Exited bool // Once Exited is true, this will contain the exit code of the process. ExitStatus int // This thing is a mutex, lock when making modifications concurrently sync.Mutex // contains filtered or unexported fields }
RemoteCmd represents a remote command being prepared or run.
type SSHCommunicator ¶
type SSHCommunicator struct {
// contains filtered or unexported fields
}
func New ¶
func New(address string, config *Config) (result *SSHCommunicator, err error)
Creates a new packer.Communicator implementation over SSH. This takes an already existing TCP connection and SSH configuration.
func (*SSHCommunicator) Start ¶
func (c *SSHCommunicator) Start(cmd *RemoteCmd) (err error)
type SSHConfig ¶
type SSHConfig struct { User string Password string KeyFile string `mapstructure:"key_file"` Host string Port int Timeout string ScriptPath string `mapstructure:"script_path"` TimeoutVal time.Duration `mapstructure:"-"` }
SSHConfig is decoded from the ConnInfo of the resource. These are the only keys we look at. If a KeyFile is given, that is used instead of a password.
func ParseSSHConfig ¶
func ParseSSHConfig(s *terraform.ResourceState) (*SSHConfig, error)
ParseSSHConfig is used to convert the ConnInfo of the ResourceState into a SSHConfig struct