-2

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 [email protected]:somerepo.git

throws this error:

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

Another attempt another error:

git push ssh://[email protected]:somerepo.git
ssh: Could not resolve hostname : Name or service not known
fatal: The remote end hung up unexpectedly
4
  • 1
    Why are you using sudo?
    – demure
    May 23, 2013 at 22:32
  • Do you get same error when git clone?
    – Raza
    May 23, 2013 at 22:34
  • sudo: just trying things. added as a remote. Didn't help. Same erro with git clone.
    – gyaani_guy
    May 23, 2013 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. Apr 7, 2019 at 10:31

2 Answers 2

2

Too many questions open for a precise answer.

sudo git push [email protected]: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://[email protected]:somerepo.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?

2

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".

2
  • 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, 2013 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. Apr 7, 2019 at 10:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .