MCPcopy Create free account
hub / github.com/coder/envbuilder / LogHostKeyCallback

Function LogHostKeyCallback

git/git.go:210–221  ·  view source on GitHub ↗

LogHostKeyCallback is a HostKeyCallback that just logs host keys and does nothing else.

(logger func(string, ...any))

Source from the content-addressed store, hash-verified

208// LogHostKeyCallback is a HostKeyCallback that just logs host keys
209// and does nothing else.
210func LogHostKeyCallback(logger func(string, ...any)) gossh.HostKeyCallback {
211 return func(hostname string, remote net.Addr, key gossh.PublicKey) error {
212 var sb strings.Builder
213 _ = knownhosts.WriteKnownHost(&sb, hostname, remote, key)
214 // skeema/knownhosts uses a fake public key to determine the host key
215 // algorithms. Ignore this one.
216 if s := sb.String(); !strings.Contains(s, "fake-public-key ZmFrZSBwdWJsaWMga2V5") {
217 logger("🔑 Got host key: %s", strings.TrimSpace(s))
218 }
219 return nil
220 }
221}
222
223// SetupRepoAuth determines the desired AuthMethod based on options.GitURL:
224//

Callers 1

SetupRepoAuthFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected