func getSSHCommandWithSSHPassFromDriver(d Driver, args ...string) (*exec.Cmd, error) { host, err := d.GetSSHHostname() if err != nil { return nil, err } port, err := d.GetSSHPort() if err != nil { return nil, err } user := d.GetSSHUsername() passwd := "" // this is the hack to make it return a password rather than key path if d0, ok := d.(interface { GetSSHPasswd() string }); ok { passwd = d0.GetSSHPasswd() if passwd == "" { keyPath := d.GetSSHKeyPath() return ssh.GetSSHCommand(host, port, user, keyPath, args...), nil } } return ssh.GetSSHCommandWithSSHPass(host, port, user, passwd, args...), nil }
func (h *Host) GetSSHCommand(args ...string) (*exec.Cmd, error) { if driver, ok := h.Driver.(interface { GetSSHPasswd() string }); ok { addr, err := h.Driver.GetSSHHostname() if err != nil { return nil, err } user := h.Driver.GetSSHUsername() port, err := h.Driver.GetSSHPort() if err != nil { return nil, err } passwd := driver.GetSSHPasswd() // if password got cleared, use publickey if passwd == "" { return h.getSSHCommand(args...) } cmd := ssh.GetSSHCommandWithSSHPass(addr, port, user, passwd, args...) return cmd, nil } return h.getSSHCommand(args...) }