Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unable to skip strict host key checking when known_hosts file is missing #382

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading