1

I have ec2 server with ubuntu 12.04, I have added one more user "git" to server. Generated ssh key and uploaded to both users .ssh directory. So now i can access my server as

ssh ubuntu@example.com
ssh git@example.com

I have created a bare repository to /opt/git/gitpg.git and added this as remote to my local repository as

sudo git remote add deploy ubuntu@example.com:/opt/git/gitpg.git

When i tried to push to this repository, it shows authentication error.

sudo git push deploy master
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

I also tried this solution, but it also doesn't work.

Can anyone please suggest what may be the possible reason ?

Update

When i tried git push deploy master instead of sudo git push deploy master it succeed to connect but unable to push due to permission.

Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 356 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
To ubuntu@example.com:/opt/git/gitpg.git
   d6cc9c3..25ddaa4  master -> master
error: unable to create directory for .git/refs/remotes/deploy/master
error: Cannot lock the ref 'refs/remotes/deploy/master'.

Update 2

I changed local directory permission to current user now it working without sudo. But i still don't know why it is nor working with sudo.

Community
  • 1
  • 1
hemc4
  • 1,623
  • 3
  • 18
  • 32

1 Answers1

0

Try to put your public key in the server in .ssh/authorized_keys or use another protocol like this:

ssh://ubuntu@example.com/opt/git/gitpg.git
Banago
  • 1,350
  • 13
  • 22
  • Thanks @Banago, when i use ssh:// it says ssh: `Could not resolve hostname example.com:: Name or service not known` – hemc4 Mar 04 '14 at 06:30
  • Yes, I had put an extra colon on the example. You need it only when you specify a port. – Banago Mar 04 '14 at 19:47