Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the SSH executable path configurable #4937

Merged
merged 1 commit into from
Jul 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions command/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type SSHCommand struct {
flagNoExec bool
flagMountPoint string
flagStrictHostKeyChecking string
flagSSHExecutable string
flagUserKnownHostsFile string

// SSH CA Mode options
Expand Down Expand Up @@ -203,6 +204,15 @@ func (c *SSHCommand) Flags() *FlagSets {
"user certificate. This is specified as a comma-separated list of values.",
})

f.StringVar(&StringVar{
Name: "ssh-executable",
Target: &c.flagSSHExecutable,
Default: "ssh",
EnvVar: "VAULT_SSH_EXECUTABLE",
Completion: complete.PredictAnything,
Usage: "Path to the SSH executable to use when connecting to the host",
})

return set
}

Expand Down Expand Up @@ -473,7 +483,7 @@ func (c *SSHCommand) handleTypeCA(username, ip, port string, sshArgs []string) i
// Add extra user defined ssh arguments
args = append(args, sshArgs...)

cmd := exec.Command("ssh", args...)
cmd := exec.Command(c.flagSSHExecutable, args...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
Expand Down Expand Up @@ -522,7 +532,7 @@ func (c *SSHCommand) handleTypeOTP(username, ip, port string, sshArgs []string)
// only the Go libraries. Feel free to try and remove this dependency.
args := make([]string, 0)
env := os.Environ()
sshCmd := "ssh"
sshCmd := c.flagSSHExecutable

sshpassPath, err := exec.LookPath("sshpass")
if err != nil {
Expand All @@ -537,7 +547,7 @@ func (c *SSHCommand) handleTypeOTP(username, ip, port string, sshArgs []string)
sshCmd = sshpassPath
args = append(args,
"-e", // Read password for SSHPASS environment variable
"ssh",
c.flagSSHExecutable,
)
env = append(env, fmt.Sprintf("SSHPASS=%s", string(cred.Key)))
}
Expand Down Expand Up @@ -634,7 +644,7 @@ func (c *SSHCommand) handleTypeDynamic(username, ip, port string, sshArgs []stri
// Add extra user defined ssh arguments
args = append(args, sshArgs...)

cmd := exec.Command("ssh", args...)
cmd := exec.Command(c.flagSSHExecutable, args...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
Expand Down