How to push code to GitHub using SSH keys without entering credentials

I set up SSH authentication for my GitHub repository by creating a key pair without any passphrase. After adding the public key to my GitHub account settings, I tested the connection and got the expected success message. The SSH test worked fine and confirmed my authentication was properly configured.

However, when I try to push my commits to the remote repository, Git still prompts me to enter my username and password every time. I was expecting it to use the SSH key automatically and skip the credential prompt entirely.

What am I missing in my setup? Is there something else I need to configure to make Git use SSH authentication instead of asking for my login details during push operations?

This happens because your repository is still configured to use HTTPS instead of SSH for the remote connection. Even though you have SSH keys set up correctly, Git will continue using HTTPS authentication if that’s how the remote URL is configured. Check your current remote configuration first. If it shows an HTTPS URL starting with https://github.com, that explains why you’re getting credential prompts. You need to update the remote URL to use the SSH format. I encountered this exact issue when I first switched to SSH authentication. The key insight is that SSH key authentication only works when Git actually connects via SSH protocol, not HTTPS. Your SSH test worked because it specifically tested the SSH connection, but your repository was still trying to push over HTTPS. After changing the remote URL to the SSH format, your pushes should work seamlessly without any credential prompts.

u might’ve cloned with https. ssh keys work, but git sticks to the protocol used. run git remote get-url origin to see. if it shows https://github.com, switch it to [email protected] format to fix the issue.

u probably still have https set as ur remote. run git remote -v and if it shows https, change it to ssh. use git remote set-url origin [email protected]:username/repo.git to fix it. that should solve ur cred issue.