Skip to content

Commit 391e348

Browse files
committed
fix: unable to skip strict host key checking when known_hosts file is missing
1 parent a7faba1 commit 391e348

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

pkg/lagoon/ssh/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,14 @@ Add correct host key in %s to get rid of this message`
163163

164164
// add interactive known hosts to reduce confusion with host key errors
165165
func InteractiveKnownHosts(userPath, host string, ignorehost, accept bool) (ssh.HostKeyCallback, []string, error) {
166+
if ignorehost {
167+
// if ignore provided, just skip the hostkey verifications
168+
return ssh.InsecureIgnoreHostKey(), nil, nil
169+
}
166170
kh, err := knownhosts.NewDB(path.Join(userPath, ".ssh/known_hosts"))
167171
if err != nil {
168172
return nil, nil, fmt.Errorf("couldn't get ~/.ssh/known_hosts: %v", err)
169173
}
170-
if ignorehost {
171-
// if ignore provided, just skip the hostkey verifications
172-
return ssh.InsecureIgnoreHostKey(), kh.HostKeyAlgorithms(host), nil
173-
}
174174
// otherwise prompt or accept for the key if required
175175
return ssh.HostKeyCallback(func(hostname string, remote net.Addr, key ssh.PublicKey) error {
176176
filePath := path.Join(userPath, ".ssh/known_hosts")

0 commit comments

Comments
 (0)