我可以向我的用户代理永久添加ssh私钥吗?
有些菜鸟问题,但是每天当我打开git bash时,我都必须启动ssh-agent守护进程,并且必须将ssh-private密钥添加到用户代理中,以便Github知道我是谁.
Somewhat of a noob question but everyday at work when I open git bash I have to start the ssh-agent daemon and I have to add my ssh-private key to the user-agent so that Github knows who I am.
- 评估"$(ssh-agent -s)"
- ssh-add〜/.ssh/id_rsa
如果我不这样做,我将无法拉/推到github.
If I dont do this I cannot pull/push to github.
每天都要这样做有点烦人,有没有办法永久添加它?
It gets a little annoying to have to do this everyday, is there a way to add it permanently?
不要使用 ssh-agent
,而是将以下内容放在您的 .ssh/config
文件中:
Instead of using ssh-agent
, put the following in your .ssh/config
file:
Host github.com
IdentityFile ~/.ssh/id_rsa
代理主要用于避免在 .ssh/config
中创建大量配置(因为任何连接都会尝试使用代理中找到的密钥),或者用于允许远程SSH会话以返回到本地计算机以获取必要的密钥.
An agent is primarily useful either to avoid creating a large number of configurations in .ssh/config
(as any connection will attempt to use a key found in the agent), or for allowing remote SSH sessions to reach back to your local machine for necessary keys.