如何将SSH私钥添加到Intellij以便用于Git

4

在使用Git时,我通常使用命令行工具。如果要将更改推送到服务器,我需要使用以下命令将公钥添加到SSH会话中:

$ eval "$(ssh-agent -s)"
ssh-add "D:/Dev/Books Spaces/Version Control with Git and GitHub/SSH/key"
Enter passphrase for D:/Dev/Books Spaces/Version Control with Git and GitHub/SSH/key:
Identity added: D:/Dev/Books Spaces/Version Control with Git and GitHub/SSH/key (me*****d@outlook.com)

现在我想使用SSH来使用Intellij。我该如何将私钥添加到Intellij中?目前它会打印以下信息: enter image description here
1个回答

6

由于您的ssh密钥不是标准的(在%USERPROFILE%\.ssh\id_rsa中),因此您需要创建一个%USERPROFILE%\.ssh\config文件来引用该密钥。

Host github
  Hostname github.com
  User git
  IdentityFile "D:/Dev/Books Spaces/Version Control with Git and GitHub/SSH/key"

请尝试使用原始的远程URL:github:xxxx/tacos01.git

谢谢,这很有效。你有这方面的文章链接吗?我想多了解一些。 - usertest
@usertest 太棒了!我还记得在2012年使用过这个(https://dev59.com/AGfWa4cB1Zd3GeqPh4z_#12066973)。SSH配置文件的所有参数都在https://www.ssh.com/ssh/config中有详细描述。示例可以参考https://www.cyberciti.biz/faq/create-ssh-config-file-on-linux-unix/。 - VonC

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接