(comment string)
| 536 | } |
| 537 | |
| 538 | func generateSSHPublicKey(comment string) ([]byte, error) { |
| 539 | publicKey, _, err := ed25519.GenerateKey(cryptorand.Reader) |
| 540 | if err != nil { |
| 541 | return nil, err |
| 542 | } |
| 543 | |
| 544 | sshPublicKey, err := ssh.NewPublicKey(publicKey) |
| 545 | if err != nil { |
| 546 | return nil, err |
| 547 | } |
| 548 | |
| 549 | authorizedKey := bytes.TrimSpace(ssh.MarshalAuthorizedKey(sshPublicKey)) |
| 550 | if comment != "" { |
| 551 | authorizedKey = append(authorizedKey, ' ') |
| 552 | authorizedKey = append(authorizedKey, comment...) |
| 553 | } |
| 554 | return append(authorizedKey, '\n'), nil |
| 555 | } |
| 556 | |
| 557 | func sandboxFilePath(root, currentDir, name string) (string, error) { |
| 558 | if filepath.IsAbs(name) { |
no outgoing calls
no test coverage detected