SSH publickey error when trying to push to server using git-Collection of common programming errors
I am trying to use this tutorial to set up a git remote repo on my server: http://toroid.org/ams/git-website-howto
But when I try to push to the server, I get this error:
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
So it seems like git can’t ssh the server because of some auth key issue. I can SSH into the server fine from Terminal by using ssh aws1
due to the set up of my ssh config file.
~/.ssh/config file:
Host aws1
HostName 54.235.193.228
User ubuntu
IdentityFile ~/.ssh/ec2_key.pem
The git commands I am using to add the remote and push:
git remote add web ssh://54.235.193.228/home/ubuntu/somedirectory.git
git push web +master:refs/heads/master
I think my problem is i don’t quite understand fully how to use ssh key-pairs. The tutorial says:
“I assume that the web site will live on a server to which you have ssh access, and that things are set up so that you can ssh to it without having to type a password (i.e., that your public key is in ~/.ssh/authorized_keys and you are running ssh-agent locally).”
I don’t know what ssh-agent is and I don’t even have an authorized_keys file on my machine (I do have one called known_hosts). I thought using the ssh config file would be adequate because that allows me to ssh from the terminal without a password but apparently that is not correct. What am I doing wrong?
Server: EC2 instance, Ubuntu 12.04, AWS elastic ip
Dev Machine: OS X 10.7.5, zsh shell