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

Use hostname instead of the IP when running the actual ssh command with vault ssh #4673

Merged
merged 1 commit into from
Jun 1, 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
8 changes: 4 additions & 4 deletions command/ssh.go
Original file line number Diff line number Diff line change
@@ -331,7 +331,7 @@ func (c *SSHCommand) Run(args []string) int {
case ssh.KeyTypeCA:
return c.handleTypeCA(username, hostname, ip, sshArgs)
case ssh.KeyTypeOTP:
return c.handleTypeOTP(username, ip, sshArgs)
return c.handleTypeOTP(username, hostname, ip, sshArgs)
case ssh.KeyTypeDynamic:
return c.handleTypeDynamic(username, ip, sshArgs)
default:
@@ -482,7 +482,7 @@ func (c *SSHCommand) handleTypeCA(username, hostname, ip string, sshArgs []strin
}

// handleTypeOTP is used to handle SSH logins using the "otp" key type.
func (c *SSHCommand) handleTypeOTP(username, ip string, sshArgs []string) int {
func (c *SSHCommand) handleTypeOTP(username, hostname string, ip string, sshArgs []string) int {
secret, cred, err := c.generateCredential(username, ip)
if err != nil {
c.UI.Error(fmt.Sprintf("failed to generate credential: %s", err))
@@ -515,7 +515,7 @@ func (c *SSHCommand) handleTypeOTP(username, ip string, sshArgs []string) int {
"-o UserKnownHostsFile=" + c.flagUserKnownHostsFile,
"-o StrictHostKeyChecking=" + c.flagStrictHostKeyChecking,
"-p", cred.Port,
username + "@" + ip,
username + "@" + hostname,
}, sshArgs...)
cmd = exec.Command("ssh", args...)
} else {
@@ -525,7 +525,7 @@ func (c *SSHCommand) handleTypeOTP(username, ip string, sshArgs []string) int {
"-o UserKnownHostsFile=" + c.flagUserKnownHostsFile,
"-o StrictHostKeyChecking=" + c.flagStrictHostKeyChecking,
"-p", cred.Port,
username + "@" + ip,
username + "@" + hostname,
}, sshArgs...)
cmd = exec.Command(sshpassPath, args...)
env := os.Environ()