我可以向我的用户代理永久添加ssh私钥吗? [英] Can I permanently add ssh private key to my user agent?

查看:65
本文介绍了我可以向我的用户代理永久添加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.

  1. 评估"$(ssh-agent -s)"
  2. 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.

这篇关于我可以向我的用户代理永久添加ssh私钥吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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