.ssh config with amazon ec2 and git

不问归期 提交于 2019-11-27 02:05:54
VonC

It usually is a permission issue.
The chmod on the parent directories of your config file might be different between your two computers.
(and I am not talking about just the immediate parent directory .ssh, but also all the parent directories)

See "Git SSH authentication", but also know that if any of the parent directories is writable for group or world, ssh won't work.


Note also that your second command is not right, and should be:

git clone ubuntu@ec2xxx.compute-1.amazonaws.com/var/www/project.git

no ':' (a ':' means using a config file, with an scp-like syntax)

it can only work if you have ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub though.
If you have mykey.pem, then you need a config file for ssh to know where are your public and private keys, which means only this can work:

git clone ec2server:/var/www/project.git

One other chack (after this thread and this forum) is to check if there is any DNS/DHCP issue (a bit like in "Working with git behind a dynamic DNS").

Host ec2server
   Hostname 1xx.xxx.xxx.xxx # ip address of ec2XXX.compute-1.amazonaws.com
   User ubuntu
   IdentityFile ~/.ssh/mykey.pem

Recently I had to re-install the system which held the working configuration and I have not managed to replicate it, so it's not about the linux version (very likely). What I managed to do, is that I managed to use the mentioned original script to clone the repository into my home directory. Here it picked up the name correctly, but if I navigated into /var/www, what I was doing before, it just gave me the same error: could ec2server not found ... . So I figure the problem has to do something with the permissions + commands combination. If anyone can figure it out how to make it work, I will mark he's response as a correct answer, until then I am marking mine as the correct one, since this is the closest to the correct.

UPDATE

I figured it out what was the problem: I had to change the permission on /var/www folder in order to be able to clone into that directory. Now it's 777 ( used only for dev on a local machine).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!