0

I to signed in Github and clone repository from there. Then I made some corrections and commit them. When I tried push changes to the server with such command

git push origin master

I get following

Warning: Permanently added the RSA host key for IP address '192.30.252.129' to he list of known hosts. Permission denied (publickey). fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

In my Github settings I see following

There are no deploy keys for this repository

ETartaren
  • 170
  • 3
  • 15
  • 2
    https://help.github.com/articles/generating-ssh-keys/ – Holloway Nov 13 '15 at 10:58
  • @Holloway I maked this steps in Git Bash. 'ls -al ~/.ssh' command show me three SSH keys: github_rsa github_rsa.pub known_hosts Then I ran the command eval $(ssh-agent -s) ssh-add ~/.ssh/github_rsa clip < ~/.ssh/github_rsa.pub Then I added the keys to GitHub and make ssh -T git@github.com Did get the answer Hi username! You've successfully authenticated, but GitHub does not # provide shell access. Then I repeated 'git push origin master' and again got Permission denied (publickey). – ETartaren Nov 13 '15 at 12:12
  • Do you have permission to push to the repo? Is it yours? – Holloway Nov 13 '15 at 12:32
  • No it not mine but I have permission. – ETartaren Nov 13 '15 at 12:35
  • The owner of the repository might need to add your key to their allowed committers list. – Holloway Nov 13 '15 at 12:36
  • 'ssh -vT git@github.com' gives 'Permission denied (publickey)' – ETartaren Nov 13 '15 at 12:55
  • The owner said I am in allowed committers list. – ETartaren Nov 13 '15 at 12:56
  • You mention the key is called github_rsa. The default is id_rsa so you might have to specify the file. Try `ssh -v -i ~/.ssh/github_rsa git@github.com` – Holloway Nov 13 '15 at 13:38
  • Answer: Hi username! You've successfully authenticated, but GitHub does not # provide shell access. – ETartaren Nov 13 '15 at 14:10
  • Looks like that's the problem then. I'll write it into an answer – Holloway Nov 13 '15 at 14:13

1 Answers1

0

The problem is that git is looking for the default key file when doing the push but your key file is called something different (github_rsa instead of id_rsa). This in itself isn't an issue but if you don't have mutliple keys, you could just rename it (or create a symlink to it).

If you have multiple keys, have a look at this question.

You need to set up an ssh config file (quite useful anyway) and use it to specify the key file to use. Something like

Host github
    HostName github.com
    User git
    IdentityFile /home/whoever/.ssh/github_rsa

then use github instead of git@github.com in your push command/gitconfig

Community
  • 1
  • 1
Holloway
  • 6,412
  • 1
  • 26
  • 33
  • When I tried 'git push origin master' and enter a passphrase, I get this ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'git@github.com:username/myproject.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. I did 'git pull' and repeat 'push' but got same message. – ETartaren Nov 15 '15 at 17:04
  • Did the pull compete successfully? – Holloway Nov 15 '15 at 20:13
  • Now the pull complete successfully and the push too. Thank you very much. – ETartaren Nov 16 '15 at 07:39