mirror of https://github.com/containers/podman.git
Add support for host keys for non-22 ports
When not using the standard SSH port (22), the port is appended
to the hostname (in brackets) like so: "host" -> "[host]:1234"
Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
(cherry picked from commit 8794e8db1c
)
This commit is contained in:
parent
bce8331528
commit
6f6cf87f8f
|
@ -214,19 +214,23 @@ func sshClient(_url *url.URL, secure bool, passPhrase string, identity string) (
|
||||||
authMethods = append(authMethods, ssh.Password(string(pass)))
|
authMethods = append(authMethods, ssh.Password(string(pass)))
|
||||||
}
|
}
|
||||||
|
|
||||||
callback := ssh.InsecureIgnoreHostKey()
|
|
||||||
if secure {
|
|
||||||
key := terminal.HostKey(_url.Hostname())
|
|
||||||
if key != nil {
|
|
||||||
callback = ssh.FixedHostKey(key)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
port := _url.Port()
|
port := _url.Port()
|
||||||
if port == "" {
|
if port == "" {
|
||||||
port = "22"
|
port = "22"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
callback := ssh.InsecureIgnoreHostKey()
|
||||||
|
if secure {
|
||||||
|
host := _url.Hostname()
|
||||||
|
if port != "22" {
|
||||||
|
host = fmt.Sprintf("[%s]:%s", host, port)
|
||||||
|
}
|
||||||
|
key := terminal.HostKey(host)
|
||||||
|
if key != nil {
|
||||||
|
callback = ssh.FixedHostKey(key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bastion, err := ssh.Dial("tcp",
|
bastion, err := ssh.Dial("tcp",
|
||||||
net.JoinHostPort(_url.Hostname(), port),
|
net.JoinHostPort(_url.Hostname(), port),
|
||||||
&ssh.ClientConfig{
|
&ssh.ClientConfig{
|
||||||
|
|
Loading…
Reference in New Issue