How to add multiple ssh keys for a single github account
Hey there, fellow code wranglers! Today, I'm going to spill the beans on a little trick that saved my bacon during my early developer internships. Picture this: you're happily using your personal GitHub account with SSH, and boom! Suddenly, you need to juggle multiple SSH keys. Sound familiar?
Step-by-Step Guide to Adding Your First SSH Key (Yes, it's a breeze!)
Fire up that Terminal:
Generate your SSH key: Replace
<your_email_id>
with your GitHub email,<id_rsa_name>
with a name you want for your RSA file and run this nifty little command :ssh-keygen -t rsa -b 4096 -C “<your_email_id>” -f ~/.ssh/id_rsa_name
Start your ssh-agent: This might vary based on your setup, but generally, you can kick it off with:
eval "$(ssh-agent -s)"
(Pro tip: You need to do this only once.)
Add that SSH key to your ssh-agent: Replace
id_rsa_name
if yours is different. Here's the command:ssh-add ~/.ssh/id_rsa_name
Config time: Edit your SSH config file like so: Replace name in
Host
andIdentityFile
parameters accordinglycat >> ~/.ssh/config << SSHConfigEoF Host name.github.com HostName github.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa_name SSHConfigEoF`
Hook it up with GitHub: Add your SSH key to your GitHub account. Check out their guide if you need a hand. adding ssh to Github
Rinse and Repeat for More Keys: When cloning new repos, use a slight twist in the command: Assuming your repo link is
git clone
git@github.com
:<user>/<repo_name>
replace withgit clone
git@name.github.com
:<user>/<repo_name>
.name
is theHost
you gave in step5
Quick Security Check: Permissions Matter!
Config file (
rw-r--r-
): You can read and write; others can just peek.Private key (
id_rsa
,rw-------
): Eyes only for you – full access, but keep it under wraps!Public key (
id_
rsa.pub
,rw-r--r--
): You can read and write; others can just peek.
There you have it, folks – a quick trip through the world of multiple SSH keys. Whether you're a seasoned dev or just dipping your toes in the tech pool, remember: there's always a way around those pesky tech hurdles.
Connect with Me
Email: sebinsebzz2002@gmail.com
GitHub: github.com/sebzz2k2