为什么我需要在我的Powershell配置文件中运行`ssh-add`?

Cha*_*ell 7 powershell posh-git

在我的Microsoft.PowerShell_profile.ps1文档中,我必须添加ssh-add ~/.ssh/github_rsa以下poshgit示例,以便它连接到我的GitHub存储库.

# Load posh-git example profile
. 'C:\tools\poshgit\dahlbyk-posh-git-8aecd99\profile.example.ps1'

ssh-add ~/.ssh/github_rsa
Run Code Online (Sandbox Code Playgroud)

如果我在我的个人资料中没有这个,我尝试连接时Github会给我权限错误.

如果我手动执行,它将在我的桌面会话的整个持续时间内工作,但是一旦我重新启动计算机,我需要重新运行该命令.

为什么poshgit和ssh-add不记得我添加的rsa?每次都必须重新添加它似乎是错误的.

Lug*_*age 21

这是因为您的rsa密钥不是默认名称(id_rsa),因此您需要使用ssh-add(将其添加到正在运行的服务中,该服务会记住使用您的密码解密的密钥),或者只需在您的密码中添加一个条目 ~\.shh\config

~\.ssh\config (创建或编辑):

Host github.com
    HostName github.com
    User git
    IdentityFile ~/.ssh/github_rsa
Run Code Online (Sandbox Code Playgroud)

或者,如果github是你唯一使用ssh键的东西,只需将密钥重命名为id_rsa然后git(well ssh.exe)会自动找到它并且poshgit会为你添加ssh(处理密码).