git config --list # View config of git
SSH uses two keys, a public key and a private key.
To add an SSH key to your GitHub account, follow these steps:
Generate a new SSH key (if you don't already have one):
Open your terminal.
Run the command to generate a new SSH key, replacing your email with the email associated with your GitHub account:
cd ~/.ssh
ssh-keygen -t ed25519
When prompted to "Enter a file in which to save the key," press Enter to accept the default file location.
At the prompt, type a secure passphrase.
Start the ssh-agent in the background:
Run the following command:
eval "$(ssh-agent -s)"
Add your SSH private key to the ssh-agent:
ssh-add ~/.ssh/id_ed25519
Add your SSH key to your GitHub account:
Copy the SSH key to your clipboard with:
If xclip
isn't installed, you can install it with sudo apt-get install xclip
or simply open the file and copy the contents manually.
cat ~/.ssh/id_ed25519.pub | xclip -sel clip
Go to GitHub and log in to your account.
Click your profile photo, then click Settings.
In the user settings sidebar, click SSH and GPG keys.
Click New SSH key or Add SSH key.
In the "Title" field, add a descriptive label for the new key. For example, if you're using your personal laptop, you might call this key "Personal Laptop".
Paste your key into the "Key" field.
Click Add SSH key.
Test your SSH connection:
Open your terminal and enter:
ssh -T [email protected]
If everything is set up correctly, you will see a message saying you've successfully authenticated, but GitHub does not provide shell access.
This process adds your SSH key to GitHub, allowing you to push and pull from repositories without needing to enter your username and password each time.