(comment string)
| 494 | } |
| 495 | |
| 496 | func generateSSHPublicKey(comment string) ([]byte, error) { |
| 497 | publicKey, _, err := ed25519.GenerateKey(cryptorand.Reader) |
| 498 | if err != nil { |
| 499 | return nil, err |
| 500 | } |
| 501 | |
| 502 | sshPublicKey, err := ssh.NewPublicKey(publicKey) |
| 503 | if err != nil { |
| 504 | return nil, err |
| 505 | } |
| 506 | |
| 507 | authorizedKey := bytes.TrimSpace(ssh.MarshalAuthorizedKey(sshPublicKey)) |
| 508 | if comment != "" { |
| 509 | authorizedKey = append(authorizedKey, ' ') |
| 510 | authorizedKey = append(authorizedKey, comment...) |
| 511 | } |
| 512 | return append(authorizedKey, '\n'), nil |
| 513 | } |
| 514 | |
| 515 | func sandboxFilePath(root, currentDir, name string) (string, error) { |
| 516 | if filepath.IsAbs(name) { |
no outgoing calls
no test coverage detected