getHostKeys returns the SSH host key signers, generating an ed25519 key in ~/.config/tailcat/ssh/ if one doesn't exist.
()
| 313 | // getHostKeys returns the SSH host key signers, generating an ed25519 key |
| 314 | // in ~/.config/tailcat/ssh/ if one doesn't exist. |
| 315 | func getHostKeys() ([]gossh.Signer, error) { |
| 316 | dir, err := sshKeyDir() |
| 317 | if err != nil { |
| 318 | return nil, err |
| 319 | } |
| 320 | keyPEM, err := hostKeyFileOrCreate(dir) |
| 321 | if err != nil { |
| 322 | return nil, err |
| 323 | } |
| 324 | signer, err := gossh.ParsePrivateKey(keyPEM) |
| 325 | if err != nil { |
| 326 | return nil, fmt.Errorf("parsing host key: %w", err) |
| 327 | } |
| 328 | return []gossh.Signer{signer}, nil |
| 329 | } |
| 330 | |
| 331 | func sshKeyDir() (string, error) { |
| 332 | cfgDir, err := os.UserConfigDir() |
no test coverage detected