Using the SSH protocol, you can connect and authenticate to remote servers and services. With SSH keys, you can connect to GitHub without providing your username and password at each commit or push as well, which can save you a lot of time. This tutorial will walk you through setting up an SSH key pair on your server, and GitHub.
Generating a key pair via SSH
- Login to your terminal via SSH
- Generate a key pair by running the following command, substituting in your GitHub email address between the quotes
ssh-keygen -t rsa -b 4096 -C "email@example.com"
- When you’re prompted to “Enter a file in which to save the key,” press Enter to save it in the default location. If you wish to use a different location, you can provide the path to be used here as well.
- At the prompt, type a secure passphrase that will be used when your key is authenticating, and confirm it
Congratulations! You now know how to generate an SSH key pair. Now we are going to walk you through the steps needed to supply your public key to GitHub for authentication.
Adding your public key to GitHub
- View your public key by running the following command, substituting the file path with the one you used in the previous tutorial if you did not use the default location
- Select and copy the entire key to your clipboard
- Login to your GitHub account
- In the upper-right corner the GitHub website, click your profile photo, then click Settings.
- On the left hand side, select SSH and GPG Keys.
- Select New SSH key or Add SSH key.
- In the “Title” field, add a label for the new key.
- Paste your key into the “Key” field.
- Select Add SSH key.
- If prompted, confirm your GitHub password.
Congratulations! You now know how to set up your SSH key pair on your server, and use your public key to connect via SSH to GitHub.
200+ Design Templates + 1 Kick-ass SuperTheme
6 WordPress Plugins + 2 Essential Services
Everything you need to build and manage WordPress websites in one Central place.