Why I can't connect to github.com using ssh?

Issue

I want push my branch onto my github account. I have created ssh key, so I can connect via ssh:

[email protected]:~/qtprojects$ ssh [email protected]
PTY allocation request failed on channel 0
Hi krv76! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.

but when I’m trying git push I got the following:

[email protected]:~/qtprojects$ git push origin master
Username for 'https://github.com': krv76
Password for 'https://[email protected]': 
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/krv76/signal.git/'

I expect connection without checking my username and password.

What I’m forget or what I’m doing wrong?

Solution

You need to set the remote URL to use the ssh protocol, not the https protocol.

When you go to GitHub, the "Code" button lets you pick the protocol: choose "SSH" (snapshot arbitrarily taken from the git-reference repo):

enter image description here

When you clone your repo, use that URL in the first place. But since you’ve already cloned with https, you can change the remote url now like this (guessing your URL from your error log):

git remote set-url origin [email protected]:krv76/signal.git

Answered By – joanis

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published