From 46e01aa504af290eac8bde14a9f3f00dbeb7fc5f Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Wed, 4 Sep 2024 16:13:01 -0500 Subject: [PATCH] fix: unable to skip strict host key checking when known_hosts file is missing (#382) --- pkg/lagoon/ssh/main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/lagoon/ssh/main.go b/pkg/lagoon/ssh/main.go index c5e5adea..882a6a34 100644 --- a/pkg/lagoon/ssh/main.go +++ b/pkg/lagoon/ssh/main.go @@ -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")