This section explains how to add an SSH key to GitHub so you can securely interact with repositories without entering your username and password every time.
SSH (Secure Shell) allows GitHub to identify you using cryptographic keys instead of passwords, making Git operations faster and more secure.
# Generate a new SSH key using RSA algorithm
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
# Display the public SSH key
cat ~/.ssh/id_rsa.pub
# Test SSH authentication with GitHub
ssh -T git@github.com
# Successful authentication message
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
# Clone repository using SSH URL
git clone git@github.com:username/repository.git
# Push commits to GitHub
git push origin main
# Pull latest changes from GitHub
git pull origin main