Authentication Failure on Github even after adding SSH key - github

I get fatal:Authenication Failure when I try to push code to my repo. I've added the public key on my github account as well. When I do :
ssh -i git#github.com
I get
Hi amangupta052! You've successfully authenticated, but GitHub does not provide shell access.
Can anyone help?
Thanks

That depends on the remote url you have used.
If git remote -v returns:
https://github.com/username/reponame
Then your ssh setup won't matter. But this would work:
ssh://git#github.com:username/reponame
Another cause is linked to your private key: if it is pass-phrase protected, with a special character in it, that usually don't work well.
See here for other ssh causes of failure.
To replace your remote named origin, use git remote commands:
git remote set-url origin ssh://git#github.com:username/reponame
(as explained in the GitHub help page about changing the rmeote url)
If you see::
ssh: Could not resolve hostname github.com:amangupta052:
Name or service not known
fatal: The remote end hung up unexpectedly
Try the non-scp ssh syntax:
git remote set-url origin ssh://git#github.com/username/reponame
(note the '/' instead of the ':' after github.com)
Maybe this would have worked, as commented in this blog post:
git remote set-url origin git#github.com:username/reponame
(scp-like syntax, but without the ssh:// prefix)
As I mention here, an scp syntax usually means an ~/.ssh/config file to work properly.

Related

GitBucket SSH Based Authentication

I configured the SSH based authentication as below
Created a public key on my UNIX server
Added the public key on my Bitbucket repository with reading and write privileges (also tried it at account level)
changed the URL from https to SSH at bitbucket and Unix server
verified the URL using and it is displaying SSH URL only
Then Tried to push, but I am getting the below error:
Permission denied (public key). fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
I have read and write access to the repository
push command
git push -u origin master
Any idea?
You should try:
GIT_SSH_COMMAND="ssh -Tv" git push
You will see what Git is using as an SSH key, and if there are any error messages.
If the error persists, it is possible there is something preventing SSH to operate properly (as in here, when not connected to a VPN)
Using HTTPS, of course, is a workaround:
git remote set-url origin https://git#bitbucket.XXX.com/XXX.com/XXX.git
After discussion, the missing step was to add the private key to the ssh-agent
ssh-add OEDQ_BIT added the private key

Pushing to GitHub without a key

I am using GitHub and C9 on a work computer and but GitHub will stop reading my SSH key after a few hours. IDK if it is because I am using my work computer (job is not currently programming), but is there a way I can push my code without an SSH key
First, check that your remote URL is indeed an ssh one:
cd /path/to/my/local/cloned/repo
git remote -v
If it is (git#github.com:user/repo), check what ssh -Tv git#github.com returns.
If SSH does not work (because SSH port might be blocked at work), switch to an HTTPS URL:
git remote set-url origin https://github.com/user/repo
From there, make sure git config credential.helper does reference an helper (like "manager" on Windows), and you will be prompted for your GitHub account username/password at the first push. After that, your credentials will be cached.

Still requiring login after SSH authentication

I followed everything in the GitHub tutorial: https://help.github.com/articles/generating-ssh-keys
I did all the commands in the directory of my repository.
I reached the end of tutorial successfully and got the message: "Hi username! You've successfully authenticated, but GitHub does not # provide shell access."
However when I tried to do things such as push it still requested for my username and password.
Check your remotes via git remote -v.
https:// URLs will always ask for a password, unless you configure a credential helper. More info on that in this question.
The simplest solution for password-less git access would be to use the git remote set-url command and set an SSH url for the existing repo.
In your case, git remote set-url origin git#github.com:name/repo.
Then you should be able to git push origin <branch> without being asked for a password.
Good that you have correctly setup your git ssh now you need to reclone the git repository with ssh for example previously you would have done something like this :
git clone https://github.com/dangrossman/bootstrap-daterangepicker.git
this was a https clone now you need to clone with ssh as
git clone git#github.com:dangrossman/bootstrap-daterangepicker.git
you can find the ssh link from your github account same place where you found your https link.
After this you can easily push without your password prompt .
It might though ask for your ssh unlock password. You then need to enter the paraphase you gave during the creation of your ssh key . If you left it blank it might not prompt for it .
I was able to stop the username & password prompt by opening .git/config from the base repo directory and changing the remote URL.
For example:
[remote "origin"]
url = https://github.com/username/my-repo.git
should be changed to:
[remote "origin"]
url = git#github.com:username/my-repo.git
I tried the answer marked as correct but couldn't make it work. This worked for me instead git remote set-url origin ssh://git#github.com/username/reponame

Git hub pushing to a forked repo

I'm new to github and I couldn't seem to find a solution to my problem, so bear with me a little.
I'm trying to push changes that I've made to a forked repo via command line on an ec2 ubuntu instance from aws. After making changes to my file, I committed the file I changed and then pushed it over to git:
ubuntu#ip-172-31-33-24:~/bitstarter$ git push origin master
Username for 'https://www.github.com': edasaur
Password for 'https://edasaur#www.github.com':
fatal: Authentication failed
I'm hypothesizing that this might be an issue with the fact that I'm pushing over to a forked repo because when I attempted to commit and push changes over to a repository that I started, it seemed to work. However, I'm at a loss at what to do. When I tested whether my SSH key worked via the command:
ubuntu#ip-172-31-33-24:~/bitstarter$ ssh -T git#github.com
Hi edasaur! You've successfully authenticated, but GitHub does not provide shell access.
Thanks in advance!
First, you are pushing using an https address, so any ssh settings you might have won't have any bearing on the completion of the (https) push.
Second, the right https url you should use is:
https://edasaur#github.com/edasaur/bitstarter.git
(no need for www.github.com)
(I like to put the username in the url: that is one less data to enter when pushing)
That means you can set your url with:
git remote set-url origin https://edasaur#github.com/edasaur/bitstarter.git
Third, double-check your password (and see if there is any special character in it like an '#', which might not be directly supported over an http query)
If nothing works, you can still fallback on ssh url:
git remote set-url origin git#github.com:edasaur/bitstarter.git

GitHub -> 'The remote end hung up unexpectedly'

I am trying to push a project (Calico) to GitHub, and am running into an error. I've successfully logged in via a ssh connection, and received the usual response:
Ryan#RYANLAPTOP-PC /C/inetpub/wwwroot/Calico (master)
$ ssh git#github.com
Enter passphrase for key '/c/Users/Ryan/.ssh/id_rsa':
Hi rossryan! You've successfully authenticated, but GitHub does not provide shel
l access.
Connection to github.com closed.
However, I am still receiving an error when I attempt to push the code:
Ryan#RYANLAPTOP-PC /C/inetpub/wwwroot/Calico (master)
$ git push -u github master
The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
Connection abandoned.
fatal: The remote end hung up unexpectedly
I believe I've followed the instructions rather faithfully from the website, substituting 'GitHub' for 'origin' in the right areas (origin is apparently already defined, so I used a different name). I've emailed GitHub about this problem, but have received no response.
Does anyone have any other ideas?
EDIT:
Output from git remote -v:
Ryan#RYANLAPTOP-PC /C/inetpub/wwwroot/Calico (master)
$ git remote -v
github git#github.com:rossryan/Calico.git (fetch)
github git#github.com:rossryan/Calico.git (push)
origin C:/inetpub/wwwroot/Calico/ (fetch)
origin C:/inetpub/wwwroot/Calico/ (push)
git push origin master fails was about that error when using putty (instead of the packaged openssh included with msysgit). I don't think that is your case.
git - Server host key not cached is about that same error, and proposes to establish an ssh connection, which you did (and it didn't propose to add github to your $HOME/ssh/known_hosts file, so this isn't the issue either.
What you need to check is:
why are you pushing to github instead of the default name 'origin' (did you really add a remote (upstream) repo named 'github'?)
What exact address is behind the remote name 'github'. A right address for pushing would be (from GitHub man page on remote):
an ssh URL git#github.com:user/repo.git
or an https URL such like https://user#github.com/user/repo.git