.ssh 配置与亚马逊 ec2 和 git [英] .ssh config with amazon ec2 and git

查看:31
本文介绍了.ssh 配置与亚马逊 ec2 和 git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在从亚马逊 ec2 服务器克隆 git 存储库时遇到了一个奇怪的问题.它在我的一台运行 ubuntu 12.04 的计算机上没有任何问题,而在另一台使用 12.10 的计算机上它给了我一个错误:

I have a strange problem with cloning a git repository from an amazon ec2 server. 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:

ssh: Could not resolve hostname ec2server: Name or service not known  
fatal: The remote end hung up unexpectedly

就好像它无法识别我的配置文件.我使用以下 git 命令来克隆:

It's like it is not recognizing my config file. I use the following git command to clone :

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

sudo git clone ec2xxx.compute-1.amazonaws.com:/var/www/project.git

这两个配置文件在两台电脑上都是一样的,在 ~./ssh 里面,内容如下:

The two config files are identical on both computers, inside the ~./ssh with the following content:

Host ec2server
   Hostname ec2XXX.compute-1.amazonaws.com
   User ubuntu
   IdentityFile ~/.ssh/mykey.pem

如果我将 ec2server 替换为实际地址,则会出现以下错误:

If I substitute the ec2server with the actual address I get the following error:

Cloning into 'project'...
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

提前致谢.

推荐答案

最近我不得不重新安装保存工作配置的系统,但我没有设法复制它,所以这与 linux 版本无关(很可能).我设法做的是,我设法使用提到的原始脚本将存储库克隆到我的主目录中.在这里它正确地选择了名称,但是如果我导航到/var/www,我之前在做什么,它只是给了我同样的错误: could ec2server not found ... .所以我认为问题必须与权限 + 命令组合有关.如果有人能弄清楚如何使它起作用,我会将他的回答标记为正确答案,在那之前我会将我的回答标记为正确答案,因为这是最接近正确的答案.

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.

更新

我想出了问题所在:我必须更改/var/www 文件夹的权限才能克隆到该目录中.现在是 777(仅用于本地机器上的开发).

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).

这篇关于.ssh 配置与亚马逊 ec2 和 git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆