So I have a local repo and a server with git installed and a git user.

I want to send (push) the repo to the server. When I simply login to the server via ssh I have to specify my .pem file and a passphrase.

The following:

sudo git push git@333.3.3.3..3:somerepo.git

throws this error:

 Permission denied (publickey).
 fatal: The remote end hung up unexpectedly

Another attempt another error:

git push ssh://git@
ssh: Could not resolve hostname : Name or service not known
fatal: The remote end hung up unexpectedly
  • 1
    Why are you using sudo? – demure May 23 '13 at 22:32
  • Do you get same error when git clone? – Raza May 23 '13 at 22:34
  • sudo: just trying things. added as a remote. Didn't help. Same erro with git clone. – gyaani_guy May 23 '13 at 22:41
  • sudo is the cause of more problems than it solves (in the hands of a novice). But the sudo down and step away. – ctrl-alt-delor Apr 7 at 10:31

Too many questions open for a precise answer.

sudo git push git@333.3.3.3..3:somerepo.git

Are you sure this is a valid IP address?
(sudo is definitely wrong here.)

Permission denied (publickey).

Your server seems to allow ssh connection only via publickey. Did you create a key pair? did you put the public key on the server? Does ssh-add add the key to your agent?

git push ssh://git@ ssh: Could not resolve hostname : Name or service not known

Is this another host? Does it contain a repo, too? Seems like it just does not exist.

How did you create the repository on the server? Are you able to ssh into the server?


First, make sure ssh works to the server. Then, go on the server and create a bare repo "mkdir repo", "cd repo", "git init --bare". Then, from your machine you can do a "git push ssh:user@server:repo".

  • I'm making the assumption you don't have a repo on the server yet versus having one and trying to push. – pcm May 26 '13 at 22:27
  • If you ssh to the server, you may get the error “Shell access is disabled.”, this is OK and shows that it is working. – ctrl-alt-delor Apr 7 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.