I know that a lot of similar questions exist here (and I read a lot of them before posting this one), but this one is different, so please stay with me for a while.
Few days ago I configured my remote git repository on amazon ec2. After hours of struggling I made it working and was able to push
files there. I was working with it for a day or two pushing resources to it without any problems (I saw every update properly).
Today, for some reason I can not push anything to it from my local machine.
git push deploy
ends up with the following error message (the same one I see when I try to get info about deploy: git remote show deploy
):
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
The first part of it (before permission denied) I was able to see previously, but it was still pushing everything correctly back then.
Deploy exist because I can clearly see it with git remote -v
:
deploy ssh://[email protected]/home/ubuntu/repo (fetch)
deploy ssh://[email protected]/home/ubuntu/repo (push)
I can correctly ssh to my server, also my private key has 0400
permissions. On both machines I have ubuntu 12.04 LTS
.
I thought that may be there is some problem with my public key, so I went ahead and recreate it from private key: ssh-keygen -y -f key.pem > key.pub
. Based on its sha
it is identical to my previous public key: sha1sum key_prev.pub
= sha1sum key.pub
I still went to the server and added a new key to authorized keys as well.
Still no changes. I can not push anything. Can anyone tell me what is the problem here and why it happened? Do I need to do anything with my local .ssh/known_hosts
?
Also in one of the answers I found the following:
Please note that after restarting the instance, the dns name changed.
I fell for this several times. The keyfile was still valid, but the
"servername" changed.
I actually restarted my machine, so I think this is highly relevant. The problem is that I can not understand what should I change now.
After reading the answer of VonC.
I can not ssh to the server by doing ssh [email protected]
(I got Permission denied (publickey).
), but I can do this with ssh myAlias
, where myAlias is defined in ~/.ssh/config
Host myAlias
Hostname X.X.X.X
User ubuntu
IdentityFile path/to/mypem/file.pem
When I have done git config --global push.default simple
I have another problem when doing git push deploy
:
fatal: The current branch master has no upstream branch. To push the
current branch and set the remote as upstream, use
git push --set-upstream deploy master
I will try to do ssh -Tvv [email protected]
and will tell how it goes.
See Question&Answers more detail:
os