Skip to content

Commit

Permalink
fix: unable to skip strict host key checking when known_hosts file is…
Browse files Browse the repository at this point in the history
… missing
  • Loading branch information
rocketeerbkw committed Sep 4, 2024
1 parent a7faba1 commit 391e348
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/lagoon/ssh/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,14 @@ Add correct host key in %s to get rid of this message`

// add interactive known hosts to reduce confusion with host key errors
func InteractiveKnownHosts(userPath, host string, ignorehost, accept bool) (ssh.HostKeyCallback, []string, error) {
if ignorehost {
// if ignore provided, just skip the hostkey verifications
return ssh.InsecureIgnoreHostKey(), nil, nil
}
kh, err := knownhosts.NewDB(path.Join(userPath, ".ssh/known_hosts"))
if err != nil {
return nil, nil, fmt.Errorf("couldn't get ~/.ssh/known_hosts: %v", err)
}
if ignorehost {
// if ignore provided, just skip the hostkey verifications
return ssh.InsecureIgnoreHostKey(), kh.HostKeyAlgorithms(host), nil
}
// otherwise prompt or accept for the key if required
return ssh.HostKeyCallback(func(hostname string, remote net.Addr, key ssh.PublicKey) error {
filePath := path.Join(userPath, ".ssh/known_hosts")
Expand Down

0 comments on commit 391e348

Please sign in to comment.