Use SSH on GitHub
Below are the detailed step-by-step instructions for configuring and using SSH on GitHub from scratch:
Check for an existing SSH Key
First, check if you have an existing SSH key locally:
|
|
If the id_rsa
and id_rsa.pub
files exist, an SSH Key already exists and you can skip the generation step.
Generate an SSH Key
If you do not have an SSH Key, you can generate one using the following command:
|
|
Press Enter
to use the default settings.
Get SSH Public Key Content
After generating the SSH Key, get the content of the public key in one of the two ways:
- run the following command:
|
|
- open
id_rsa.pub
file intxt
Copy the contents.
Add the Public Key on GitHub
→ Log in to GitHub
→ Go to Settings
→ Select SSH and GPG keys
→ Click New SSH key
→ Paste the copied contents of the public key into the Key
text box
→ Click Add SSH key
Verify the SSH Configuration
Verify that the configuration was successful using the following command in the terminal:
|
|
If it says Hi username! You've successfully authenticated, but GitHub does not provide shell access
, then the configuration was successful.
Clone and Push Code
After successful configuration, you can clone and push code using SSH URLs.
- Clone the repository:
|
|
- Push the code:
|
|