// GetSSHCommand returns a command that will run over SSH on the GCE instance. func (driver *Driver) GetSSHCommand(args ...string) (*exec.Cmd, error) { ip, err := driver.GetIP() if err != nil { return nil, err } return ssh.GetSSHCommand(ip, 22, driver.UserName, driver.sshKeyPath, args...), nil }
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 (c *ComputeUtil) executeCommands(commands []string, ip, sshKeyPath string) error { for _, command := range commands { cmd := ssh.GetSSHCommand(ip, 22, c.userName, sshKeyPath, command) if err := cmd.Run(); err != nil { return fmt.Errorf("error executing command: %v %v", command, err) } } return nil }
func GetSSHCommandFromDriver(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() keyPath := d.GetSSHKeyPath() return ssh.GetSSHCommand(host, port, user, keyPath, args...), nil }
func (driver *Driver) GetSSHCommand(args ...string) (*exec.Cmd, error) { err := driver.setUserSubscription() if err != nil { return nil, err } vmState, err := driver.GetState() if err != nil { return nil, err } if vmState == state.Stopped { return nil, fmt.Errorf("Azure host is stopped. Please start it before using ssh command.") } return ssh.GetSSHCommand(driver.getHostname(), driver.SSHPort, driver.UserName, driver.sshKeyPath(), args...), nil }
func (h *Host) getSSHCommand(args ...string) (*exec.Cmd, error) { 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 } keyPath := h.Driver.GetSSHKeyPath() cmd := ssh.GetSSHCommand(addr, port, user, keyPath, args...) return cmd, nil }
func (d *Driver) GetSSHCommand(args ...string) (*exec.Cmd, error) { return ssh.GetSSHCommand("localhost", d.SSHPort, "docker", d.sshKeyPath(), args...), nil }
func (d *Driver) GetSSHCommand(args ...string) (*exec.Cmd, error) { return ssh.GetSSHCommand(d.IPAddress, 22, "ubuntu", d.sshKeyPath(), args...), nil }