Skip to content

Instantly share code, notes, and snippets.

@ryansechrest
Last active March 1, 2023 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryansechrest/790d26f163abf32811cd78921e0f1692 to your computer and use it in GitHub Desktop.
Save ryansechrest/790d26f163abf32811cd78921e0f1692 to your computer and use it in GitHub Desktop.
Create SSH Key

Create SSH Key

1a. Use ed25519 algorithm

ssh-keygen -t ed25519 -C "your_email@example.com"
  • -t Specifies the type of key to create.
  • -C Provides a new comment.

1b. Use rsa algorithm

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
  • -t Specifies type of key to create.
  • -b Specifies number of bits in the key to create.
  • -C Provides new comment.

2. Enter passphrase when prompted

3. Add to ~/.ssh/config file

Use selected algorithm in file name.

Host *
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_ed25519
  • AddKeysToAgent Specifies whether keys should be automatically added to running ssh-agent.
  • UseKeychain Specifies whether passphrase should be stored in keychain.
  • IdentifyFile Specifies file authentication identity is read from.

4. Store passphrase in keychain

Use selected algorithm in file name.

ssh-add --apple-use-keychain ~/.ssh/id_ed25519

Enter passphrase again when prompted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment