DecodeBase64PrivateKey attempts to decode a base64 encoded private key and returns an ssh.Signer
(key string)
| 192 | // DecodeBase64PrivateKey attempts to decode a base64 encoded private |
| 193 | // key and returns an ssh.Signer |
| 194 | func DecodeBase64PrivateKey(key string) (gossh.Signer, error) { |
| 195 | bs, err := base64.StdEncoding.DecodeString(key) |
| 196 | if err != nil { |
| 197 | return nil, fmt.Errorf("decode base64: %w", err) |
| 198 | } |
| 199 | |
| 200 | k, err := gossh.ParsePrivateKey(bs) |
| 201 | if err != nil { |
| 202 | return nil, fmt.Errorf("parse private key: %w", err) |
| 203 | } |
| 204 | |
| 205 | return k, nil |
| 206 | } |
| 207 | |
| 208 | // LogHostKeyCallback is a HostKeyCallback that just logs host keys |
| 209 | // and does nothing else. |