配置Git以使用来自特定位置的.pem密钥 [英] Configure Git to use a .pem key from a specific location
问题描述
每当我尝试做一个"git pull origin master"时,我都会得到它(不是Github):
Whenever I try to do a 'git pull origin master' I get (It is NOT Github):
权限被拒绝(公钥).
Permission denied (publickey).
我能够通过SSH进入我的AWS EC2 Linux服务器,该服务器具有裸存储库,当遇到上述权限错误时,我将尝试从中提取该存储库.
I am able to SSH into my AWS EC2 Linux sever, which has the bare repository, which I'm trying to pull from when I get the aforementioned permission error.
我确实已经将公钥复制到了该服务器,因为我可以通过ssh成功登录,但只能通过以下操作进行登录:
I have indeed copied the public key to that server, because I can login successfully via ssh, but only by doing a:
ssh -i /location/of/pemkey/mykey.pem ec2-user@ec2-12-34-56-78.us-east-compute.amazonaws.com
我需要配置Git以使用我的'.pem'键. 如何完成设置Git以使用我的'.pem'密钥?
I need to configure Git to use my '.pem' key. How do I accomplish setting up Git to utilize my '.pem' key?
推荐答案
在git(1)
手册页中:
GIT_SSH
If this environment variable is set then git fetch and git push
will use this command instead of ssh when they need to connect to a
remote system. The $GIT_SSH command will be given exactly two or
four arguments: the username@host (or just host) from the URL and
the shell command to execute on that remote system, optionally
preceded by -p (literally) and the port from the URL when it
specifies something other than the default SSH port.
To pass options to the program that you want to list in GIT_SSH you
will need to wrap the program and options into a shell script, then
set GIT_SSH to refer to the shell script.
Usually it is easier to configure any desired options through your
personal .ssh/config file. Please consult your ssh documentation
for further details.
以我的个人经验,即使对于仅用户名不同的主机,在.ssh/config
中添加主机设置的一次性成本也有很大的不同.
In my personal experience, the one-time cost of adding host settings in .ssh/config
has made a big difference, even for hosts where only the username is different.
这篇关于配置Git以使用来自特定位置的.pem密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!