[英].ssh config with amazon ec2 and git
I have a strange problem with cloning a git repository from an amazon ec2 server. 从亚马逊ec2服务器克隆git存储库我有一个奇怪的问题。 It works without any problems on one of my computers running ubuntu 12.04, while on another one using 12.10 it gives me an error:
它在我的一台运行ubuntu 12.04的计算机上运行没有任何问题,而在另一台使用12.10的计算机上它给我一个错误:
ssh: Could not resolve hostname ec2server: Name or service not known
fatal: The remote end hung up unexpectedly
It's like it is not recognizing my config file. 这就像它没有识别我的配置文件。 I use the following git command to clone :
我使用以下git命令克隆:
sudo git clone ec2server:/var/www/project.git
or 要么
sudo git clone ec2xxx.compute-1.amazonaws.com:/var/www/project.git
The two config files are identical on both computers, inside the ~./ssh with the following content: 这两个配置文件在两台计算机上相同,位于〜。/ ssh中,内容如下:
Host ec2server
Hostname ec2XXX.compute-1.amazonaws.com
User ubuntu
IdentityFile ~/.ssh/mykey.pem
If I substitute the ec2server with the actual address I get the following error: 如果我用实际地址替换ec2server,我会收到以下错误:
Cloning into 'project'...
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Thanks in advance. 提前致谢。
It usually is a permission issue. 它通常是一个许可问题。
The chmod
on the parent directories of your config file might be different between your two computers. 配置文件的父目录上的
chmod
可能在两台计算机之间有所不同。
(and I am not talking about just the immediate parent directory .ssh
, but also all the parent directories) (我不是只讨论直接的父目录
.ssh
,而是所有的父目录)
See " Git SSH authentication ", but also know that if any of the parent directories is writable for group or world, ssh won't work. 请参阅“ Git SSH身份验证 ”,但也知道如果任何父目录对于组或世界是可写的,则ssh将不起作用。
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) 没有'
:
' ('' :
'表示使用config
文件,使用类似scp
的语法)
it can only work if you have ~/.ssh/id_rsa
and ~/.ssh/id_rsa.pub
though. 只有你有
~/.ssh/id_rsa
和~/.ssh/id_rsa.pub
才能工作。
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: 如果你有mykey.pem,那么你需要 ssh的
config
文件来知道你的公钥和私钥在哪里,这意味着只有这个可以工作:
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 "). 另一个chack(在此主题和此论坛之后 )检查是否存在任何DNS / DHCP问题(有点像“ 使用动态DNS背后的git ”)。
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). 最近我不得不重新安装具有工作配置的系统,我还没有设法复制它,所以它不是关于linux版本(非常可能)。 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 ... .
在这里,它正确地选择了名称,但是如果我导航到/ var / www,我以前做过什么,它只是给了我同样的错误:可能找不到ec2server .... 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 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. 我想出了问题所在:我必须更改/ var / www文件夹的权限才能克隆到该目录中。 Now it's 777 ( used only for dev on a local machine).
现在它是777(仅用于本地机器上的dev)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.