Created
June 9, 2025 10:45
-
-
Save piersolenski/632858bc30a9b25bb9325c13664a5171 to your computer and use it in GitHub Desktop.
Generate SSH Key
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Taken from https://github.com/driesvints/dotfiles/blob/main/ssh.sh | |
echo "Generating a new SSH key for GitHub..." | |
# Generating a new SSH key | |
# https://docs.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key | |
ssh-keygen -t ed25519 -C $1 -f ~/.ssh/id_ed25519 | |
# Adding your SSH key to the ssh-agent | |
# https://docs.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#adding-your-ssh-key-to-the-ssh-agent | |
eval "$(ssh-agent -s)" | |
touch ~/.ssh/config | |
echo "Host *\n AddKeysToAgent yes\n UseKeychain yes\n IdentityFile ~/.ssh/id_ed25519" | tee ~/.ssh/config | |
ssh-add -K ~/.ssh/id_ed25519 | |
# Adding your SSH key to your GitHub account | |
# https://docs.github.com/en/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account | |
pbcopy <~/.ssh/id_ed25519.pub | |
echo "SSH key has been copied to the clipboard. Add it to https://github.com/settings/keys." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment