diff options
author | Anders F Björklund <anders.f.bjorklund@gmail.com> | 2020-10-27 12:17:58 +0100 |
---|---|---|
committer | Anders F Björklund <anders.f.bjorklund@gmail.com> | 2020-10-27 12:19:44 +0100 |
commit | 83e54885ff6441eafff40627a7d89c9342521b27 (patch) | |
tree | f05c5cf79efdf25162e811a2b48244a40e13bfed /pkg/terminal/util.go | |
parent | bce8331528c186ef2234a3cfe6c7d0e09da79bdd (diff) | |
download | podman-83e54885ff6441eafff40627a7d89c9342521b27.tar.gz podman-83e54885ff6441eafff40627a7d89c9342521b27.tar.bz2 podman-83e54885ff6441eafff40627a7d89c9342521b27.zip |
Support hashed hostnames in the known_hosts file
Some systems have "HashKnownHosts yes" in their ssh_config
This causes entries in the ssh known_hosts to be hashed (|)
Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
Diffstat (limited to 'pkg/terminal/util.go')
-rw-r--r-- | pkg/terminal/util.go | 6 |
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 } } |