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

Function generateSSHPublicKey

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

Source from the content-addressed store, hash-verified

1222}
1223
1224func 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
1243func sandboxFilePath(root, currentDir, name string) (string, error) {
1244 if filepath.IsAbs(name) {

Callers 2

TestGenerateSSHPublicKeyFunction · 0.85
sharedCmdsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected