diff --git a/command/ssh.go b/command/ssh.go index db190d895..4a857afe0 100644 --- a/command/ssh.go +++ b/command/ssh.go @@ -174,6 +174,9 @@ func (c *SSHCommand) Run(args []string) int { sshpassPath, err := exec.LookPath("sshpass") if err == nil { sshCmdArgs = append(sshCmdArgs, []string{"-p", string(resp.Key), "ssh", "-o UserKnownHostsFile=" + userKnownHostsFile, "-o StrictHostKeyChecking=" + strictHostKeyChecking, "-p", resp.Port, username + "@" + ip.String()}...) + if len(args) > 1 { + sshCmdArgs = append(sshCmdArgs, args[1:]...) + } sshCmd := exec.Command(sshpassPath, sshCmdArgs...) sshCmd.Stdin = os.Stdin sshCmd.Stdout = os.Stdout @@ -187,6 +190,9 @@ func (c *SSHCommand) Run(args []string) int { c.Ui.Output("[Note: Install 'sshpass' to automate typing in OTP]") } sshCmdArgs = append(sshCmdArgs, []string{"-o UserKnownHostsFile=" + userKnownHostsFile, "-o StrictHostKeyChecking=" + strictHostKeyChecking, "-p", resp.Port, username + "@" + ip.String()}...) + if len(args) > 1 { + sshCmdArgs = append(sshCmdArgs, args[1:]...) + } sshCmd := exec.Command("ssh", sshCmdArgs...) sshCmd.Stdin = os.Stdin