0

I try create new repositories on my remote git-server

cd /var/www/vhost/example.com
sudo git init
sudo git remote add origin ssh://git@111.111.111.111:30000/home/git/repositories/example.git
sudo git add .
sudo git commit -a -m "Create empty example.com dir"
sudo git push origin master:refs/heads/master

My ssh config:

Host 111.111.111.111
User git
Port 30000
IdentityFile ~/.ssh/id_rsa

My gitosis-admin.conf

[gitosis]

[group gitosis-admin]
members = git@111.111.111.111
writable = gitosis-admin

[group example-com]
members = git@111.111.111.111 user@user
writable = example-com

Get error

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

I can do

ssh git@111.111.111.111

no problem, but can't do push. What i doing wrong? I had also looked into similar previous question GitHub: Permission denied (publickey). fatal: The remote end hung up unexpectedly , but i don't use github.

UPDATE: Ok, i think problem in sudo.

This command complete whitout some sort of error:

git push origin master:refs/heads/master

This command:

sudo git push origin master:refs/heads/master

complete with error:

Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Community
  • 1
  • 1
user2112300
  • 244
  • 3
  • 9
  • 2
    The remote URL should be `ssh://git@111.111.111.111:30000/example.git` if it works remotely like gitolite nowaday does. Btw. you should really switch to [gitolite](http://gitolite.com/gitolite/), it’s gitosis’ successor. – poke Mar 12 '13 at 17:40
  • no matter, i take error Permission denied (publickey). fatal: The remote end hung up unexpectedly. – user2112300 Mar 12 '13 at 17:52
  • When you ssh into it normally, do you get a shell? If yes, you need to use a different public key for your repository and the standard ssh access. – poke Mar 12 '13 at 18:24
  • can be problem case i use "sudo git push" instead of "git push"? – user2112300 Mar 12 '13 at 20:11
  • Not really, it should work just with `git push`, so it should definitely work with even more rights. – poke Mar 12 '13 at 20:30

2 Answers2

0

wehre die you Store your SSH config, normally the config is in the Home Directory, so root has a different Home Directory and also a different SSH config, you have to save the config in the Home Directory of root i think.

D-E-N
  • 1,242
  • 7
  • 14
0

Re-run any git command by following with GIT_TRACE=1, e.g.

GIT_TRACE=1 git push origin master:refs/heads/master

So you can see more output and executed commands to check why git is failing.

If working on Windows, define GIT_TRACE user variable with any value, so it'll enable debug mode for all git commands. Remove when not needed.

You may also use: GIT_SSH_COMMAND="ssh -vv" (Git 2.3.0+).

kenorb
  • 155,785
  • 88
  • 678
  • 743