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

Function generateSSHPublicKey

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

Source from the content-addressed store, hash-verified

536}
537
538func 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
557func sandboxFilePath(root, currentDir, name string) (string, error) {
558 if filepath.IsAbs(name) {

Callers 2

TestGenerateSSHPublicKeyFunction · 0.85
sharedCmdsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected