[英]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
加載了這個證書,但在嘗試執行pull
, push
等時不會使用它。將文件重命名為id_rsa
我可以執行這些操作(如果我再次指定我的密碼) 。
雖然這有效,但我不想使用這個重命名的文件。 為了給GitHub使用不同的私鑰,我創建了以下文件~\\.ssh\\config
其中包含以下內容。
host github.com
HostName github.com
IdentityFile ~/.ssh/jan
User git
雖然這有效,但在我看來這是一個次優的解決方案。 另外,因為在使用遙控器做某事時我必須再次指定我的密碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.