Skip to content

Commit

Permalink
Merge pull request #8161 from afbjorklund/podman-remote-host-hash
Browse files Browse the repository at this point in the history
Support hashed hostnames in the known_hosts file
  • Loading branch information
openshift-merge-robot authored Oct 29, 2020
2 parents cce6c6c + 83e5488 commit fdd3260
Show file tree
Hide file tree
Showing 3 changed files with 546 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/terminal/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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())
Expand All @@ -123,7 +127,7 @@ func HostKey(host string) ssh.PublicKey {
}

for _, h := range hosts {
if h == host {
if h == host || h == hashhost {
return key
}
}
Expand Down
Loading

0 comments on commit fdd3260

Please sign in to comment.