Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I had git working before on /var/html/projectfolder and realized it was a security risk so I made a new folder /projects from the root folder and tried to replicate what I did and now it doesnt work.

Here is the backlog of what I did for my local machine and EC2 - server

Server-EC2 1.I added my public key to the authorized_user file in ~/.ssh folder 2.Create a bare repository

git init --bare

3.Change folder permissions to

sudo chgrp -R ec2-user *
sudo chmod -R g+ws *

Local Machine

  1. create a local repository with git init
  2. touch, add, commit readme file
  3. pointed origin master to ec2 via

    git remote add origin ssh://ec2-user@remote-ip/path/to/folder

This is my output:

Permission Denied (publickey)
fatal: The remote end hung up unexpectedly
share|improve this question
add comment

migrated from stackoverflow.com Sep 3 '12 at 14:49

This question came from our site for professional and enthusiast programmers.

2 Answers

The easiest way to see what going on is to do a

 ssh -Tvvv  ssh://ec2-user@remote-ip/path/to/folder

Everything matter: the exact case of the path, or the user exact name.
But also the permission of the ~/.ssh directory (in which case, have a look at the sshd logs on the server, when you are doing your ssh command from the client, which might not be possible here for an amazon-ec2 server).

See also for illustration "Creating SSH keys for Gerrit and Hudson".

share|improve this answer
    
I get this debug2: we sent a publickey packet, wait for reply debug1: Authentications that can continue: publickey debug1: Trying private key: /home/tam/.ssh/id_rsa debug3: no such identity: /home/tam/.ssh/id_rsa debug1: Trying private key: /home/tam/.ssh/id_dsa debug3: no such identity: /home/tam/.ssh/id_dsa debug1: Trying private key: /home/tam/.ssh/id_ecdsa debug3: no such identity: /home/tam/.ssh/id_ecdsa debug2: we did not send a packet, disable method debug1: No more authentication methods to try. Permission denied (publickey). –  MrNart Sep 2 '12 at 18:16
    
@MrNart are you sure you did copy the content of the public id_rsa.pub key correctly to the ~/.ssh/authorized_keys on the server: the usual issue is copying it in multiple lines instead of one line. –  VonC Sep 2 '12 at 18:18
    
VonC, I had git working on a diff folder /var/www/html/project but I realized that the folder was a security risk so I deleted the folder. I then made a new folder with a /projects/ path from home and now its not working when I try to push. –  MrNart Sep 2 '12 at 18:19
    
@MrNart make also sure every parent directory up to your ~/.ssh is not writable for group ----w---- or others -------w-. Otherwise, are you talking about the folder on the server side? In which case, it could be a path (case) issue. –  VonC Sep 2 '12 at 18:23
    
I followed and made sure of what you said also it is server side and I've made sure the case is correct. –  MrNart Sep 2 '12 at 18:27
show 1 more comment

ok so with a little bit of tinkering around, I just instead of pushing I just did a clone of the repository..after I cloned the bare repository and pulled..it seemed to work. Thanks again for the help guys.

share|improve this answer
    
What is the remote address you ended up getting after your clone? What 'git remote -v' shows in your local clone? –  VonC Sep 2 '12 at 20:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.