LogHostKeyCallback is a HostKeyCallback that just logs host keys and does nothing else.
(logger func(string, ...any))
| 208 | // LogHostKeyCallback is a HostKeyCallback that just logs host keys |
| 209 | // and does nothing else. |
| 210 | func 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 | // |