diff options
author | Paulo Gomes <pjbgf@linux.com> | 2024-07-26 19:33:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-26 19:33:47 +0100 |
commit | 80e4369fb2862ab31e360fdf68973ff98062efae (patch) | |
tree | 25c21ae20d431fec15341b378ce903c259484c01 /plumbing/transport/ssh/auth_method.go | |
parent | ec133065ea1201a4488bbc793ccd9337b6c06877 (diff) | |
parent | 20b556be6a825f0255a71376a2bce4c2c8393b89 (diff) | |
download | go-git-80e4369fb2862ab31e360fdf68973ff98062efae.tar.gz |
Merge pull request #1157 from Javier-varez/ja/knownHostsDb
plumbing: transport/ssh, Add support for SSH @cert-authority.
Diffstat (limited to 'plumbing/transport/ssh/auth_method.go')
-rw-r--r-- | plumbing/transport/ssh/auth_method.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/plumbing/transport/ssh/auth_method.go b/plumbing/transport/ssh/auth_method.go index ac4e358..f9c598e 100644 --- a/plumbing/transport/ssh/auth_method.go +++ b/plumbing/transport/ssh/auth_method.go @@ -230,11 +230,11 @@ func (a *PublicKeysCallback) ClientConfig() (*ssh.ClientConfig, error) { // ~/.ssh/known_hosts // /etc/ssh/ssh_known_hosts func NewKnownHostsCallback(files ...string) (ssh.HostKeyCallback, error) { - kh, err := newKnownHosts(files...) - return ssh.HostKeyCallback(kh), err + db, err := newKnownHostsDb(files...) + return db.HostKeyCallback(), err } -func newKnownHosts(files ...string) (knownhosts.HostKeyCallback, error) { +func newKnownHostsDb(files ...string) (*knownhosts.HostKeyDB, error) { var err error if len(files) == 0 { @@ -247,7 +247,7 @@ func newKnownHosts(files ...string) (knownhosts.HostKeyCallback, error) { return nil, err } - return knownhosts.New(files...) + return knownhosts.NewDB(files...) } func getDefaultKnownHostsFiles() ([]string, error) { @@ -301,11 +301,12 @@ type HostKeyCallbackHelper struct { // HostKeyCallback is empty a default callback is created using // NewKnownHostsCallback. func (m *HostKeyCallbackHelper) SetHostKeyCallback(cfg *ssh.ClientConfig) (*ssh.ClientConfig, error) { - var err error if m.HostKeyCallback == nil { - if m.HostKeyCallback, err = NewKnownHostsCallback(); err != nil { + db, err := newKnownHostsDb() + if err != nil { return cfg, err } + m.HostKeyCallback = db.HostKeyCallback() } cfg.HostKeyCallback = m.HostKeyCallback |