MCPcopy
hub / github.com/tailscale/tailscale / AddHostKey

Method AddHostKey

tempfork/sshtest/ssh/server.go:167–176  ·  view source on GitHub ↗

AddHostKey adds a private key as a host key. If an existing host key exists with the same public key format, it is replaced. Each server config must have at least one host key.

(key Signer)

Source from the content-addressed store, hash-verified

165// key exists with the same public key format, it is replaced. Each server
166// config must have at least one host key.
167func (s *ServerConfig) AddHostKey(key Signer) {
168 for i, k := range s.hostKeys {
169 if k.PublicKey().Type() == key.PublicKey().Type() {
170 s.hostKeys[i] = key
171 return
172 }
173 }
174
175 s.hostKeys = append(s.hostKeys, key)
176}
177
178// cachedPubKey contains the results of querying whether a public key is
179// acceptable for a user. This is a FIFO cache.

Callers 15

TestBannerErrorFunction · 0.95
tryAuthBothSidesFunction · 0.95
testPermissionsPassingFunction · 0.95
TestClientAuthNoneFunction · 0.95
TestClientAuthErrorListFunction · 0.95
dialFunction · 0.95

Calls 2

TypeMethod · 0.65
PublicKeyMethod · 0.65

Tested by 15

TestBannerErrorFunction · 0.76
tryAuthBothSidesFunction · 0.76
testPermissionsPassingFunction · 0.76
TestClientAuthNoneFunction · 0.76
TestClientAuthErrorListFunction · 0.76
dialFunction · 0.76