forked from driesvints/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ssh.sh
executable file
·22 lines (16 loc) · 1.28 KB
/
ssh.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/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
/usr/bin/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 "$(/usr/bin/ssh-agent -s)"
touch ~/.ssh/config
echo "Host *\n IgnoreUnknown UseKeychain\n AddKeysToAgent yes\n UseKeychain yes\n IdentityFile ~/.ssh/id_ed25519" | tee ~/.ssh/config
# It appears that there is another ssh-add, possibly installed by Brew, in your shell's $PATH that differs from the Apple version. When using the Apple version, -K saves your password in the keychain, eliminating the need to type it repeatedly. However, the non-Apple version -K loads resident keys from a FIDO authenticator.
# ssh-add -K ~/.ssh/id_ed25519
/usr/bin/ssh-add --apple-use-keychain ~/.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
echo "run 'pbcopy < ~/.ssh/id_ed25519.pub' and paste that into GitHub"