Skip to content

Commit

Permalink
Merge pull request #8141 from afbjorklund/podman-remote-host-port-master
Browse files Browse the repository at this point in the history
Add support for host keys for non-22 ports
  • Loading branch information
openshift-merge-robot authored Oct 27, 2020
2 parents 95f3ec7 + 6f6cf87 commit ee29328
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions pkg/bindings/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,19 +214,23 @@ func sshClient(_url *url.URL, secure bool, passPhrase string, identity string) (
authMethods = append(authMethods, ssh.Password(string(pass)))
}

port := _url.Port()
if port == "" {
port = "22"
}

callback := ssh.InsecureIgnoreHostKey()
if secure {
key := terminal.HostKey(_url.Hostname())
host := _url.Hostname()
if port != "22" {
host = fmt.Sprintf("[%s]:%s", host, port)
}
key := terminal.HostKey(host)
if key != nil {
callback = ssh.FixedHostKey(key)
}
}

port := _url.Port()
if port == "" {
port = "22"
}

bastion, err := ssh.Dial("tcp",
net.JoinHostPort(_url.Hostname(), port),
&ssh.ClientConfig{
Expand Down

0 comments on commit ee29328

Please sign in to comment.