Still typing your GitHub password every time? It's time to stop!
using SSH with Github
What is SSH?
SSH is a networking protocol which creates a secure, encrypted tunnel between you and the server.
This encrypted tunnel ensures secure access and communication over the network.
Where is SSH used on Github?
When cloning a repository, you have multiple options.
HTTPS → when you want quick and easy access without extra setup.
SSH → when you contribute often and want a secure, hassle-free experience.
Why use HTTPS?
Some networks, like college proxies, may block SSH.
Easier for accessing public repos for read-only access, where you will be contributing rarely.
Easier to set up for beginners
Why use SSH?
SSH Keys instead of id/passwords provide better security
More convenient for repeated use, contributions
Once set up, no need to type passwords at all
Personal Experience with SSH and Github
Look, I've used HTTPS for as long as I've known coding - about five years - and I recently switched to SSH.
Indeed I’m new to SSH, but the security it provides and its ease of setup and use make it totally worth using!
SSH shouldn’t be just an optional feature on GitHub — you should start using it now!
- Trust me you will stop using and generating GITHUB_TOKENS every now and then after this.
Setting up SSH for Github
Start with generating your SSH key pair
There will be a public key and private key generated at this step.
These keys are mathematically related and work together. You will be sharing the public key with Github, while your private key stays secret.
Use the following command to generate the SSH Keypair:
ssh-keygen -t ed25519 -C
"your-email@example.com"
ed25519
is an encryption algorithm used for generating SSH keys-C email
is optional but recommended, it adds a comment to the key so that the key can be identified if you are having multiple keys.
Find the generated public keys in the
~/.ssh/
directory.locate the files
id_ed25519
andid_ed25519.pub
.the
.pub
file is the public key you will be sharing with Github.Here’s how the SSH private-public key pair looks:
Go to Github→settings→keys and click on
New SSH key
It’s safe to share the public key. In fact, it's so safe that I could post mine right here on the blog.
An attacker can only encrypt a message using the public key, but only the private key can decrypt it, making it safe to share the public key.
When adding an SSH key, you'll see two options under 'Key type':
Authentication key → Used for creating the secure communication channel before push/pull requests
Signing key → Used to sign your commits, this creates your digital signature to verify your commit’s credibility.
Once you add this SSH key, just make sure your private key is in the default location: `
~/.ssh/id_ed25519
`.You are done. That’s all it takes to setup SSH with Github.
Now go ahead and clone a repository using the SSH link.
Try pushing to the repository—you won’t be asked for your ID or password anymore!
But we can save the password for HTTPS too, right?
Yes, you can use
git credential.helper
, but Git itself recommends against it for security reasons.When you use this, the <id,password/token> pair is stored as a plain text file protected only by file permissions, which is not safe at all.
- This might make HTTPS as convenient as SSH, but it doesn’t come close in terms of security.
Are you still using HTTPS for GitHub? Give SSH a try and see the difference! What’s stopping you from switching?