From e4a20c0dcdf706ded1a74a84efd4121c2f9ac427 Mon Sep 17 00:00:00 2001 From: vishalnayak Date: Mon, 1 Aug 2016 14:53:00 -0400 Subject: [PATCH] Support execution of remote commands using 'vault ssh' --- command/ssh.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/command/ssh.go b/command/ssh.go index db190d895f..4a857afe0d 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