(comment string)
| 1222 | } |
| 1223 | |
| 1224 | func generateSSHPublicKey(comment string) ([]byte, error) { |
| 1225 | publicKey, _, err := ed25519.GenerateKey(cryptorand.Reader) |
| 1226 | if err != nil { |
| 1227 | return nil, err |
| 1228 | } |
| 1229 | |
| 1230 | sshPublicKey, err := ssh.NewPublicKey(publicKey) |
| 1231 | if err != nil { |
| 1232 | return nil, err |
| 1233 | } |
| 1234 | |
| 1235 | authorizedKey := bytes.TrimSpace(ssh.MarshalAuthorizedKey(sshPublicKey)) |
| 1236 | if comment != "" { |
| 1237 | authorizedKey = append(authorizedKey, ' ') |
| 1238 | authorizedKey = append(authorizedKey, comment...) |
| 1239 | } |
| 1240 | return append(authorizedKey, '\n'), nil |
| 1241 | } |
| 1242 | |
| 1243 | func sandboxFilePath(root, currentDir, name string) (string, error) { |
| 1244 | if filepath.IsAbs(name) { |
no outgoing calls
no test coverage detected