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
Related
When I try to push my files to the git server I faced this problem.
`~ git push
fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin main
So, I've entered git push --set-upstream origin main in the terminal. It was showing up the following error.
ERROR: Permission to adivenkat05/C-Assignments.git denied to deploy key
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
So, after searching for the solution, it was that we need to upload our ssh key in the git server (Deploy Key).
I've uploaded that same key to another repository but it ended up showing me this "So, after searching for the solution, it was that we need to upload our ssh key in the git server (Deploy Key).
I've uploaded that same key to another repository but it ended up showing me this "Key is already in use".
So, it's not possible to have multiple ssh keys in a particular machine, right?
How do I tackle this problem?".
The second error is different, and refer to an authentication problem.
You can have multiple keys, a deploy one and one associated with your user account.
Create a new dedicated key, and add it to your account:
ssh-keygen -t rsa -P "" -f ~/.ssh/me
Reference it in a ~/.ssh/config file:
Host gh
Hostname github.com
User git
IdentityFile ~/.ssh/me
IdentitiesOnly yes
And your SSH URL becomes gh:me/myRepository. (no more git#github.com:...)
You can test your SSH key with ssh -Tv gh.
It it works:
cd /path/to/my/local/repo
git remote set-url origin gh:adivenkat05/C-Assignments.git
git push -u origin main
I am trying to set up to build my first website and have been following an online tutorial. When trying to link visual studio and my GitHub repository, this is the message I get:
`
samanthacanela#samanthas-air Canela Street Art % git commit -m "initialized git repository"
[main 3a08e0a] initialized git repository
2 files changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 about.html
rename homepage.html => home.html (100%)
samanthacanela#samanthas-air Canela Street Art % git push
fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin main
To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.
samanthacanela#samanthas-air Canela Street Art % git push --set-upstream origin main
The authenticity of host 'github.com (140.82.112.3)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
git#github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
samanthacanela#samanthas-air Canela Street Art %
`
I'm an absolute beginner. What the hell am I doing wrong?
I was following along a tutorial and they lost me.
Based on my understanding, I can see that you may haven't setup the origin remote URI. To fix that issue, you'll need to follow these steps.
Logging into git (If you aren't already)
Run these commands to set your display name and email when pushing:-
$ git config --global user.name "Your name here"
$ git config --global user.email "your_email#example.com"
Using HTTPS access method (recommended)
Using GitHub CLI, you can run $ git auth login and follow the steps to login.
Or if you're using GCM (Git Credential Manager)* refer to this article by GitHub
* GCM is another way to store your credentials securely and connect to GitHub over HTTPS. With GCM, you don't have to manually create and store a personal access token, as GCM manages authentication on your behalf, including 2FA (two-factor authentication).
Using SSH access method
If you clone with SSH, you must generate SSH keys on each computer you use to push or pull from GitHub. For more information, see "Generating a new SSH key."
Setting up your repository
** Make sure to run these commands inside your git environment and not globally.
#Set a new remote
git remote add origin github.com/example/example.git
#Verify new remote
git remote -v
Basically, a common cause for an error after following these steps is cloning using HTTPS method instead of SSH. You can correct this by going to your repository, clicking "Clone or download", then clicking the "Use SSH" button above the URL field and updating the URL of your origin remote like this:
$ git remote set-url origin git#github.com:ex-user/example.git
And that forces the source to be SSH.
If this still gives you an error, please refer to this answer.
For more help, refer to this document.
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
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
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.