I am on a windows machine trying to push code up to a remote git repository on an ec2 instance which runs ubuntu. I have setup the instance and created a bare repo at a location on the instance.
I have my public key on the instance cos i can ssh to it via putty and also via openssh software i installed.
i checked out
git push heroku master Permission denied (publickey)
Git - Permission denied (publickey)
but the suggested solutions were not clear to me
I can ssh into the instance using ssh -i mykey.pem ubuntu@1.1.1.1.
Problem is i have added the repo to my list of remotes but i keep getting the following error when i try to push from my local master to the remote repo using
production - ssh://ubuntu@ec2-1-1-1-1.compute-1.amazonaws.com
git push production master
Error
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I can ssh into the instance using ssh -i mykey.pem ubuntu@1.1.1.1.
This is the problem — you use mykey.pem
for ssh but git uses default key. You have to configure ssh
so that mykey.pem
is the default key for that host:
# .ssh/config
Host ec2-1-1-1-1.compute-1.amazonaws.com
User ubuntu
IdentityFile mykey.pem
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.