Skip to content

Commit

Permalink
Merge pull request #8140 from afbjorklund/podman-remote-host-port
Browse files Browse the repository at this point in the history
Add support for host keys for non-22 ports (v2.1)
  • Loading branch information
openshift-merge-robot authored Nov 18, 2020
2 parents 9b0f5dd + 8794e8d commit 9d8a948
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 9d8a948

Please sign in to comment.