Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
包括。git拉/推的pem_Git_Authentication_Amazon Web Services_Ssh_Pem - Fatal编程技术网

包括。git拉/推的pem

包括。git拉/推的pem,git,authentication,amazon-web-services,ssh,pem,Git,Authentication,Amazon Web Services,Ssh,Pem,我在AmazonEC2上保留了一个Git服务器,为了推送或拉入,我需要运行ssh add~/.ssh/pem/Me.pem。有没有办法将这个.pem文件添加到Git配置中,这样我就不必每次都运行ssh add?我正在考虑一个类似于~/.ssh/config的配置文件,它允许用户配置这样一个选项(IdentityFile~/.ssh/pem/Me.pem)。在发布之后,我灵机一动,在~/.ssh/config中添加了以下内容: Host someServer Hostname 1.2.3.

我在AmazonEC2上保留了一个Git服务器,为了
推送
拉入
,我需要运行
ssh add~/.ssh/pem/Me.pem
。有没有办法将这个
.pem
文件添加到Git配置中,这样我就不必每次都运行
ssh add
?我正在考虑一个类似于
~/.ssh/config
的配置文件,它允许用户配置这样一个选项(
IdentityFile~/.ssh/pem/Me.pem
)。

在发布之后,我灵机一动,在
~/.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
文件,效果非常好。

很好的解决方案。scp风格的someServer:/opt/git/someRepo.git URI语法对于喜欢它的人来说仍然有效。是否需要
hostname
user
字段?@PaymahnMoghadasian:如果不将字段添加到
config
文件中,则在登录时必须指定它们。我想它将与
用户
字段一起工作,请尝试并让我们知道。但是(我能想到的)没有办法指定
Hostname
字段,因此您可能必须将该字段添加到
config
文件中。