Issue
I am working remote and ssh'd into a work machine. I am trying to push code to github from my remote connection, but it keeps asking for my username and password. I know github changed the way they authenticate users, but both machines have working ssh-keys for github.
While ssh'd into machine A I ran
ssh [email protected]
and get back
PTY allocation request failed on channel 0
Hi jasperwreed! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
but then I try and run git push and it asks for my username and password.
Does anyone know why this is happening?
Solution
but then I try and run git push and it asks for my username and password.
This is because you have a "remote" that uses the https
URL rather than a ssh
one. To verify this, do git remote -v
. You will probably see output something like
origin https://github.com/myUser/myRepo.git
Note that this is using a HTTPS URL for the remote. To change this to use ssh
instead
- Open your repository in the browser
- Click on the "Code" button on the right side above the directory listing
- Select the SSH tab
- Click the copy to clipboard button
- Now open your terminal and type
git remote set-url origin
- Paste the URL and hit enter.
Now you will be able to use commands like git push
and git fetch
using SSH.
Answered By - Code-Apprentice