Merge pull request #1181 from mgukov/develop

IgnoreHostKey policy for known_hosts checking
This commit is contained in:
Denis Gukov 2023-03-12 19:24:46 +01:00 committed by GitHub
commit 648d945be6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,6 +12,8 @@ import (
"github.com/go-git/go-git/v5/plumbing/transport/http"
"github.com/go-git/go-git/v5/plumbing/transport/ssh"
"github.com/go-git/go-git/v5/storage/memory"
ssh2 "golang.org/x/crypto/ssh"
)
type GoGitClient struct{}
@ -35,6 +37,15 @@ func getAuthMethod(r GitRepository) (transport.AuthMethod, error) {
return nil, sshErr
}
clientCfg, err := publicKey.ClientConfig()
if err != nil {
r.Logger.Log("Unable to creating ssh auth method")
return nil, sshErr
}
hostKeyHelper := ssh.HostKeyCallbackHelper{HostKeyCallback: ssh2.InsecureIgnoreHostKey()}
hostKeyHelper.SetHostKeyCallback(clientCfg)
return publicKey, sshErr
} else if r.Repository.SSHKey.Type == db.AccessKeyLoginPassword {
password := &http.BasicAuth{