2013-10-07 79 views
1

我在Amazon EC2上保留一个Git服务器,并且为了pushpull它,我需要运行ssh-add ~/.ssh/pem/Me.pem。有什么办法可以将这个.pem文件添加到Git配置中,这样我就不必每次运行ssh-add?我正在考虑一个类似于~/.ssh/config的配置文件,它允许用户配置这样一个选项(IdentityFile ~/.ssh/pem/Me.pem)。包括.pem for git pull/push

回答

4

在一阵灵感刚刚发布后,我增加了以下内容~/.ssh/config

Host someServer 
    Hostname 1.2.3.4 
    User ubuntu 
    IdentityFile ~/.ssh/pem/Me.pem 

,我根本克隆Git的回购这样:

git clone ssh://someServer/opt/git/someRepo.git 

这有了不起的作用包括根据需要的.pem文件。

+1

伟大的解决方案。 scp-style someServer:/opt/git/someRepo.git URI语法对于那些喜欢它的人来说仍然适用。 –