关闭并打开新的SSH密钥后,它在git bash上不起作用 [英] SSH key not working on git bash after closing and opening new

查看:95
本文介绍了关闭并打开新的SSH密钥后,它在git bash上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已使用以下链接创建ssh密钥 ( https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/) 一旦使用git bash创建ssh密钥并添加到github.它仅适用于特定的git bash.如果我关闭git bash并再次打开.相同的ssh密钥将无法正常工作,需要创建新的密钥.可以请任何人告诉我为什么会这样吗?还是缺少什​​么?

Have create ssh key using following link (https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/) Once create ssh key using git bash and added to github. It works only for that particular git bash. If I close git bash and open again. Same ssh key wont work, need to create new. CAn anyone please tell me why is it happening? or what is missing?

推荐答案

打开Git Bash时,需要将ssh密钥自动添加到每个会话中.为此,如果您使用的是Windows,请按照以下步骤操作:

You would need to auto add the ssh key to every session when you open Git Bash. For that, if you are on Windows, follow the below steps :

  • 转到Git安装位置(通常位于C:\Program Files\Git\etc\ssh)
  • 编辑ssh_config文件,并添加IdentityFile Drive:\path\to\key行,其中Drive:\path\to\key应该指定您先前生成的密钥的本地路径,并在编辑后保存文件.
  • Go to the location of Git installation (usually at C:\Program Files\Git\etc\ssh)
  • Edit the ssh_config file and add the line IdentityFile Drive:\path\to\key where Drive:\path\to\key should specify the local path to your key that you have generated earlier, and save the file after editing.

现在,每次打开Git Bash时,密钥都会自动添加到ssh会话中,而您不必每次都添加ssh密钥.

Now every time you open Git Bash, the key would automatically be added to the ssh session and you will not need to add the ssh key everytime.

这篇关于关闭并打开新的SSH密钥后,它在git bash上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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