This guide explains how to install Git, generate an SSH key, connect it to GitHub, and use GitHub securely without passwords.
Update system packages and install Git:
sudo apt update
sudo apt install git -yVerify installation:
git --versionSet your GitHub username and email:
git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"Verify configuration:
git config --global --listGenerate a new ED25519 SSH key:
ssh-keygen -t ed25519 -C "your_email@example.com"Press Enter to accept default location: ~/.ssh/id_ed25519
(Optional) Set a passphrase for extra security.
Start the SSH agent:
eval "$(ssh-agent -s)"Add the private key (do NOT add .pub):
ssh-add ~/.ssh/id_ed25519Verify key is loaded:
ssh-add -lCopy the public key:
cat ~/.ssh/id_ed25519.pub- Go to GitHub → Settings → SSH and GPG keys
- Click New SSH key
- Add a title (example: Linux-PC)
- Paste the public key
- Click Add SSH key
Test authentication:
ssh -T git@github.comExpected output:
Hi ! You've successfully authenticated, but GitHub does not provide shell access.
This message means SSH is working correctly.
Clone a repository:
git clone git@github.com:USERNAME/REPOSITORY.gitOR change existing repo from HTTPS to SSH:
git remote set-url origin git@github.com:USERNAME/REPOSITORY.gitCheck remote URL:
git remote -vgit status
git add .
git commit -m "Initial commit"
git push origin main
git pullCreate SSH config file:
nano ~/.ssh/configAdd:
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes
git config --global url."git@github.com:".insteadOf "https://github.com/"Your GitHub SSH setup is complete and ready for development, CI/CD, and automation.