Linking SSH Key to GitHub or GitLab
Hey beginner coders! Linking your SSH key to GitHub or GitLab is ESSENTIAL to updating your repositories. Let's jump into it.
Generating your SSH Key on Mac OS
If you already have an SSH key, skip to the next section (type ls -al ~/.ssh
in your terminal to see if you have any ssh keys. Your ssh key will end in .pub
).
ssh-keygen -t ed25519 -C "your_email"
The terminal will prompt you to enter a file "in which to save the key". Select "Enter".
The terminal will prompt you to enter a passcode. Choose a passphrase of your choice and enter. Make sure to note this passphrase in a secure location.
Add SSH key to SSH agent on Mac OS
If you've already done this previously, skip to "Linking Your SSH Key to GitHub".
In your terminal type the following:
-
sudo -s -H
ORexec ssh-agent bash
ORexec ssh-agent zsh
(this depends on your environment) eval "$(ssh-agent -s)"
$ ssh-add --apple-use-keychain ~/.ssh/id_ed0000
Linking Your SSH Key to GitHub
- Log into your GitHub/GitLab account
- Navigate to "Settings" than "SSH keys"
- Select "New SSH key"
- Create a title for your key
- Paste your public key
- Click "Add SSH key" ___
What is your public key?
Type cat ~/.ssh/id_ed00000.pub
OR the name of your respective key (find file name using ls -al ~/.ssh
)
The terminal will return something that looks like ssh-ed... long_string_of_letters_and_numbers
your_email
.
Copy the ssh-...
and the long_string_of_letters_and_numbers
ONLY into the public key box on GitHub.
That's it! You're ready to pull and push changes to your repo.
QUESTION FOR EXPERIENCED CODERS!
How many SSH keys do you have? Do you make a new SSH key for every repository? Do you use the same SSH key for all work related projects? How many SSH keys do you recommend generating? Let me know in the comments.
Any tips that I missed? Let me know!
Sincerely, a beginner developer.
Resources: UC Berkeley Coding Boot Camp and GitHub.
Top comments (0)