简体   繁体   中英

Permission denied (publickey) on push into remote git-server

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

如果您存储SSH配置,通常该配置位于主目录中,那么root具有不同的主目录和另一个SSH配置,您必须将配置保存在根的主目录中。

Re-run any git command by following with GIT_TRACE=1 , eg

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+).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM