如何在windows中安装OpenSSH可以看2020-10-28-git-在windows中安装OpenSSH并在linux中使用git-clone克隆仓库
从linux命令行通过OpenSSH clone windows中的仓库失败,报错
# git clone PP@linxy_dkpc:/d/linxy/home/local-respository/2020-10-28-server-39-15-applications
'git-upload-pack' Ҳ
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
最简单的方式:默认OpenSSH使用的shell是powershell.exe,将其改为git for windows的bash.exe即可解决这个问题。
# 注意bash.exe的路径使用你自己的
PS C:\Windows\system32> New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\linxy\software\git\Git\bin\bash.exe" -PropertyType String -Force
DefaultShell : C:\linxy\software\git\Git\bin\bash.exe
PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\OpenSSH
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE
PSChildName : OpenSSH
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry
若要恢复回powershell.exe,如下
# 注意powershell.exe使用你自己的
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -PropertyType String -Force