MCPcopy Create free account
hub / github.com/cli/cli / generateSSHPublicKey

Function generateSSHPublicKey

acceptance/acceptance_test.go:496–513  ·  view source on GitHub ↗
(comment string)

Source from the content-addressed store, hash-verified

494}
495
496func 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
515func sandboxFilePath(root, currentDir, name string) (string, error) {
516 if filepath.IsAbs(name) {

Callers 2

TestGenerateSSHPublicKeyFunction · 0.85
sharedCmdsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected