I barely knew about how to set SSH keys before writing this (I wass a noob who only knew the theory), so I'm making this guide to guide others like me who want to learn more or those who want to make their GitHub as green as an Irish pasture.
Photo by Illiya Vjestica on Unsplash
This is essential for building automations like Cheeky.
No SSH, NO push. 🚫
SSH keys help us authenticate with GitHub without typing the credentials every single time our lovely Cheeky pushes a commit (which would otherwise defeat the purpose of automatization).
They're more secure and convenient due to:
- Stronger security: SSH uses cryptographic keys instead of your password, so it's harder to hack.
- Easier management: You can add multiple SSH keys to your GitHub account and revoke them without changing your password.
You can run other automated scripts too, but I hope Cheeky remains your favourite <3.
Let's check if you have anything lying around. ![]()
Open your terminal and run:
ls ~/.ssh
If you spot files like _id_rsa, ided25519 or anything that ends in .pub, you've got keys already!
If not, we'll make them in the next step.
Now, let's make our very own cryptographic key:
ssh-keygen -t ed25519 -C "[email protected]"
You’ll be asked:
-
Where to save the key. Press Enter to go with the default path: /home/you/.ssh/id_ed25519
-
Passphrase. You can add one for extra security (recommended), or just smash Enter to skip it and live on the edge.
Congratulations! You should now have two files:
-
ided25519 (_your private key, never share this!)
-
ided25519.pub (_your public key, the one we’ll give to GitHub.)
We want the system to remember the key without bugging us constantly.
First, start the ssh-agent:
eval "$(ssh-agent -s)"
Then, add your new key to it:
ssh-add ~/.ssh/id_ed25519
Done!
Time to connect your computer to your GitHub account.
Copy your public key with:
cat ~/.ssh/id_ed25519.pub
(It should look like a long line starting with ssh-ed25519 and ending with your email.)
Now, in your browser, go to:
GitHub → Settings → SSH and GPG keys → New SSH key
And fill the fields:
-
Title: I recommend making it the name of you device. Something like “Thinkpad X270” (my dear laptop) will help you remember what it is clearly.
-
Key: Paste what you copied.
-
and click Add SSH key!
If your repo was cloned using HTTPS (if you used Visual Studio, chances are it was), you’ll need to switch it to use SSH:
Open your Terminal in Visual Studio Code and run:
git remote -v
If you see https://github.com/..., it’s time for a change.
Inside your repo folder, run:
git remote set-url origin [email protected]:yourusername/your-repo.git
(Replace this with your actual username and repo name.)
That’s it. Now let’s double check that it worked:
git remote -v
You should now see:
origin [email protected]:saraleitexyz/cheeky_commit_bot.git (fetch)
origin [email protected]:saraleitexyz/cheeky_commit_bot.git (push)
(Replace with your own repo if you're not me. Unless you are me. In which case, hi.)
Now Git will use SSH for pushes, pulls and impressing those hiring managers. ![]()
For the final step, let's make sure it all works:
ssh -T [email protected]
You might be prompted to enter "yes" or "no". SSH is asking if you're are sure the connection is legit and not other machine pretending to be GitHub.
It’s totally normal the first time you connect to a new host.
- Type yes.
Now, if you see something like:
Hi y/n! You've successfully authenticated, but GitHub does not provide shell access.
Perfect, you’re in! Congrats, you've finished setting up your SSH! 𓆝 𓆟
