MCPcopy
hub / github.com/cli/cli / generateAutomaticSSHKeys

Function generateAutomaticSSHKeys

pkg/cmd/codespace/ssh.go:409–421  ·  view source on GitHub ↗
(sshContext ssh.Context)

Source from the content-addressed store, hash-verified

407}
408
409func generateAutomaticSSHKeys(sshContext ssh.Context) (*ssh.KeyPair, error) {
410 keyPair := checkAndUpdateOldKeyPair(sshContext)
411 if keyPair != nil {
412 return keyPair, nil
413 }
414
415 keyPair, err := sshContext.GenerateSSHKey(automaticPrivateKeyName, "")
416 if err != nil && !errors.Is(err, ssh.ErrKeyAlreadyExists) {
417 return nil, err
418 }
419
420 return keyPair, nil
421}
422
423// checkAndUpdateOldKeyPair handles backward compatibility with the old keypair names.
424// If the old public and private keys both exist they are renamed to the new name.

Callers 2

selectSSHKeysFunction · 0.85

Calls 2

checkAndUpdateOldKeyPairFunction · 0.85
GenerateSSHKeyMethod · 0.80

Tested by 1