1. 程式人生 > 其它 >windows powershell 支援git ssh 配置

windows powershell 支援git ssh 配置

  1. ssh-agent從 Windows 服務啟動:
  • 鍵入ServicesStart MenuWin+R,然後鍵入services.msc啟動服務視窗;
  • OpenSSH Authentication Agent在列表中找到並雙擊它;
  • OpenSSH Authentication Agent Properties窗口出現,選擇AutomaticStartup type:下拉選單,然後單擊StartService status:。確保它現在說Service status: Running
  1. 配置Git的發出在PowerShell中的以下命令來使用Windows 10執行的OpenSSH:git config --global core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe

    ;

  2. 通過編輯在 中config找到的檔案C:\Users\%YOUR_USERNAME%\.ssh\config,將SSH 配置為在啟動時自動將金鑰新增到代理,並新增以下行:

Host *
    AddKeysToAgent yes
    IdentitiesOnly yes

如果您使用自定義名稱或多個 SSH 金鑰生成了 SSH 金鑰,您還可以新增以下行:

Host github.com
    HostName github.com
    User your_user_name
    IdentityFile ~/.ssh/your_file_name
  1. ssh-agent
    通過發出ssh-add命令並輸入您的密碼將您的 SSH 金鑰新增到:
ssh-add $HOME/.ssh/your_file_name
  1. 完畢!如有必要,現在重新啟動 Powershell 甚至 Windows。