Here’s the full "zero to hero" SSH + Git procedure for Termux
Copy-paste this and you’ll never type password again.
pkg update && pkg upgrade -y pkg install git openssh -y
ssh-keygen -t ed25519 -C "your_email@gmail.com" What to press:
-
Enterto save at default location -
Enterfor no passphrase OR type one if you want extra security -
Enteragain
Output: Your public key has been saved in /data/data/com.termux/files/home/.ssh/id_ed25519.pub
cat ~/.ssh/id_ed25519.pub
Long press > Copy. It should start with ssh-ed25519 AAAA... your_email@gmail.com
-
Go to
github.com/settings/keys -
Click
New SSH key -
Title:
Termux Phone -
Key: Paste the 1 line from step 3
-
Click
Add SSH key
ssh -T git@github.com
Expected: Hi YourUsername! You've successfully authenticated
Type yes if it asks about known_hosts
THIS IS THE MOST IMPORTANT STEP
git clone git@github.com:YourUsername/repo-name.git
Now cd repo-name and you can git push / git pull with no password.
pkg install git openssh ssh-keygen -t ed25519 -C "email" cat ~/.ssh/id_ed25519.pub # copy this to github ssh -T git@github.com # test git clone git@github.com:user/repo.git # clone with SSH git remote -v # check if using ssh or https
1 Cloned with HTTPS instead of SSH Username for 'https://github.com': Change remote: git remote set-url origin git@github.com:User/Repo.git
2 Pasted wrong key to GitHub Key is invalid. Must be OpenSSH public key format You pasted private key. Run cat ~/.ssh/id_ed25519.pub and paste THAT one. Must start with ssh-ed25519
3 Bad permissions Permissions 0644 for id_ed25519 are too open chmod 700 ~/.ssh && chmod 600 ~/.ssh/id_ed25519
4 Permission denied publickey git@github.com: Permission denied (publickey) 1. Key not added to github 2. Testing with wrong email. Run ssh -T git@github.com to check which account
5 Host key verification failed Host key verification failed ssh-keyscan github.com >> ~/.ssh/known_hosts then test again
-
Auto-start ssh-agent: Add this to
~/.bashrcso you don't type passphrase eval $(ssh-agent -s) ssh-add -
Multiple GitHub accounts: Create
~/.ssh/configfile to switch keys -
Storage:
termux-setup-storageif you want to clone to/sdcard
Rule to remember:
https:// = asks password
git@github.com: = uses SSH key