繁体   English   中英

在PowerShell中添加ssh-add以添加我的Git密钥,接收权限被拒绝

[英]Did ssh-add in PowerShell to add my Git key, receiving permission denied

我正在调整我的开发控制台。 目前我正在尝试修改我的PowerShell体验,并希望将其用作我的主控制台。

这很好用,我现在正忙着在控制台上实现我的Git键,所以我可以通过PowerShell推送,拉动等。 到目前为止我所做的是安装Git for Windows,在安装Git Extensions时,我确保通过Use Git and optional Unix tools from the Windows Command Prompt选择Use Git and optional Unix tools from the Windows Command Prompt Linux命令添加到我的路径中。

之后,我运行以下命令。

# Check status of service
Get-Service ssh-agent

# Check the start type of the service
Get-Service ssh-agent | Select StartType

# Set the start type to manual
Get-Service -Name ssh-agent | Set-Service -StartupType Manual

# Start the service
Start-Service ssh-agent

# Adding my certificate
ssh-add $env:USERPROFILE\.ssh\myCertificate

在进行推送(或拉取/获取)时,我收到一条Permission denied消息。

PS> git push origin master
Warning: Permanently added the RSA host key for IP address '140.82.118.4' to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我在多个系统上收到此消息。 完全相同的密钥在安装的Git Bash控制台中起作用,因此这不应该是问题。

我的猜测是在通过PowerShell进行拉/推/提取时没有使用加载的SSH密钥,但这只是猜测。

我需要在PowerShell中配置其他东西以使用我加载的SSH密钥在Git中执行某些操作吗?

更新

我已经找到了解决办法,但这不是最理想的

我也尝试过以下命令ssh -vT git@github.com 运行此命令时,我看到很多事情发生,最后这是尝试通过我的证书C:\\\\Users\\\\jan/.ssh/myCertificate连接到GitHub。 使用此证书后,我已成功连接到GitHub。 因此,如果使用此证书,我实际上可以做的事情。

好吧,我想(部分)。

默认情况下,Git会搜索名为id_rsa的密钥,该密钥在我的系统中不存在。 我已经将我的私钥命名为jan (或者在myCertificate上面的问题中。

即使我已经通过ssh-add加载了这个证书,但在尝试执行pullpush等时不会使用它。将文件重命名为id_rsa我可以执行这些操作(如果我再次指定我的密码) 。

虽然这有效,但我不想使用这个重命名的文件。 为了给GitHub使用不同的私钥,我创建了以下文件~\\.ssh\\config其中包含以下内容。

host github.com
 HostName github.com
 IdentityFile ~/.ssh/jan
 User git

虽然这有效,但在我看来这是一个次优的解决方案。 另外,因为在使用遥控器做某事时我必须再次指定我的密码。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM