summaryrefslogtreecommitdiff
path: root/pkg/terminal
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-10-29 06:31:20 -0400
committerGitHub <noreply@github.com>2020-10-29 06:31:20 -0400
commitfdd32604cf75fc310afca209adad15b1bcecfef7 (patch)
tree9523aa76c5d110a747c03f1fc4c164ebba4c244c /pkg/terminal
parentcce6c6cd40137c460f173300b36c5868383870c5 (diff)
parent83e54885ff6441eafff40627a7d89c9342521b27 (diff)
downloadpodman-fdd32604cf75fc310afca209adad15b1bcecfef7.tar.gz
podman-fdd32604cf75fc310afca209adad15b1bcecfef7.tar.bz2
podman-fdd32604cf75fc310afca209adad15b1bcecfef7.zip
Merge pull request #8161 from afbjorklund/podman-remote-host-hash
Support hashed hostnames in the known_hosts file
Diffstat (limited to 'pkg/terminal')
-rw-r--r--pkg/terminal/util.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/pkg/terminal/util.go b/pkg/terminal/util.go
index ab3dc54e4..169bec2af 100644
--- a/pkg/terminal/util.go
+++ b/pkg/terminal/util.go
@@ -12,6 +12,7 @@ import (
"github.com/sirupsen/logrus"
"golang.org/x/crypto/ssh"
+ "golang.org/x/crypto/ssh/knownhosts"
"golang.org/x/crypto/ssh/terminal"
"k8s.io/client-go/util/homedir"
)
@@ -114,6 +115,9 @@ func HostKey(host string) ssh.PublicKey {
return nil
}
+ // support -H parameter for ssh-keyscan
+ hashhost := knownhosts.HashHostname(host)
+
scanner := bufio.NewScanner(fd)
for scanner.Scan() {
_, hosts, key, _, _, err := ssh.ParseKnownHosts(scanner.Bytes())
@@ -123,7 +127,7 @@ func HostKey(host string) ssh.PublicKey {
}
for _, h := range hosts {
- if h == host {
+ if h == host || h == hashhost {
return key
}
}