Support execution of remote commands using 'vault ssh'

This commit is contained in:
vishalnayak 2016-08-01 14:53:00 -04:00
parent 3c01b9a22c
commit e029d3c87a
1 changed files with 6 additions and 0 deletions

View File

@ -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