Last active
March 25, 2024 17:07
-
-
Save lmgeorge/4563fee4f5b382301c5997aa0010f9c0 to your computer and use it in GitHub Desktop.
Generate ssh keys for a new machine
This file contains 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/bash | |
mkdir ~/.ssh | |
touch ~/.ssh/authorized_keys | |
touch ~/.ssh/known_hosts | |
cat <<EOF > ~/.ssh/config | |
Host * | |
User ${USER} | |
IdentityFile ~/.ssh/host.key | |
Host github.com | |
HostName github.com | |
User git | |
IdentitiesOnly yes | |
IdentityFile ~/.ssh/github.key | |
EOF | |
ssh-keygen -t rsa -b 4096 -N '' -f ~/.ssh/host.key | |
ssh-keygen -t rsa -b 4096 -N '' -f ~/.ssh/github.key | |
# Set permissions | |
chmod 700 ~/.ssh | |
chmod 644 ~/.ssh/* | |
chmod 600 -f ~/.ssh/*.key |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment