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)
| 165 | // key exists with the same public key format, it is replaced. Each server |
| 166 | // config must have at least one host key. |
| 167 | func (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. |