Add GitHub SSH keys to authorized_user file

Last updated July 23, 2019 | e4a001f

If you have an SSH key you regularly use elsewhere added to your GitHub account, this one-liner to get those public keys and add them to the ~/.ssh/authorized_keys file of your current machine. It will also create the ~/.ssh/authorized_keys file if your current machine doesn’t have one.

Notice: Be sure to swap out $USERNAME for your GitHub username below!


if ! [[ -f ~/.ssh/authorized_keys ]]; then touch ~/.ssh/authorized_keys; fi && curl https://github.com/$USERNAME.keys | tee -a ~/.ssh/authorized_keys