Lesson

Git What is SSH?

10 min reading
Free Course

Git What is SSH?: Passwordless, Encrypted Remote Access

SSH (Secure Shell) is an encrypted network protocol that authenticates your computer to remote Git servers like GitHub without typing passwords or personal access tokens on every push. Instead of sharing a secret password over the network, SSH proves your identity using a mathematical key pair.

How Public and Private SSH Keys Work

An SSH key pair consists of two linked files stored inside your ~/.ssh/ folder:

  • Private key (id_ed25519): Stays strictly on your computer and must never be shared, emailed, or committed to a repository.
  • Public key (id_ed25519.pub): Safe to upload to GitHub, GitLab, or deployment servers.

When you run git push, GitHub sends a cryptographic challenge encrypted for your public key. Only your local private key can sign the matching response, verifying your identity automatically.

Generating a Modern Ed25519 SSH Key

Modern Git hosts recommend Ed25519 keys because they are shorter, faster, and stronger than legacy RSA keys. Generate a new key pair in Git Bash, macOS Terminal, or Linux:

ssh-keygen -t ed25519 -C "amina@example.com"

Press Enter to save the key in the default ~/.ssh/id_ed25519 path, then enter a strong passphrase to protect the private key file on disk.

Loading Your Key into ssh-agent

Start the background SSH agent and register your private key so you do not have to re-type your key passphrase on every command:

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

On macOS, add UseKeychain yes inside ~/.ssh/config so Keychain remembers your passphrase across reboots.

Common SSH Mistakes

Copying or pasting the private key (id_ed25519) instead of the .pub public key exposes your credentials and gets rejected by GitHub. Always verify the .pub extension before uploading.

Another common issue is storing ~/.ssh/id_ed25519 with overly open file permissions on Linux or WSL. Fix permissions with chmod 600 ~/.ssh/id_ed25519 if SSH refuses to load your key.

Frequently Asked Questions

Should I use HTTPS or SSH for Git remotes?

SSH is usually more convenient for daily development because you configure your key once and push without token prompts. HTTPS works well behind strict corporate firewalls that block SSH port 22.

Can I use the same SSH public key on multiple laptops?

You can, though generating a separate SSH key per machine is safer. If one laptop is lost or replaced, you can revoke just that key on GitHub without breaking access on your other devices.

What if my system does not support Ed25519?

Older legacy servers occasionally require RSA keys. Generate a 4096-bit RSA key instead using ssh-keygen -t rsa -b 4096 -C "amina@example.com".

Save Your Progress

Unlock Your
Full Potential.

Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.

Quick Access With

Enterprise-Grade Security Protocol
Git Topic Hub

Stuck on this lesson?

Join our community of senior developers.

Ask in Forum