Windows 10 SSH 客户端:无密码访问

Tho*_* S. 12 ssh openssh keychain windows-10

我想纯粹使用 Windows 10 内置的 SSH 客户端 -没有 plink ,没有 putty

我可以轻松地使用登录到我的服务器

$ ssh user@server
Run Code Online (Sandbox Code Playgroud)

但它总是要求我输入密码。使用私钥时

$ ssh user@server -i %USERPROFILE%\.ssh\id_rsa
Run Code Online (Sandbox Code Playgroud)

它还要求我输入密码。Windows SSH 客户端是否能够将凭据存储在钥匙串中的某个地方,例如 macOS?

小智 16

作为 Thomas S. 答案的补充,我找到了一种 Windows 可以记住密码的方法,即使在重新启动后也是如此。这使用 PowerShell。

在提升的 PowerShell 会话中运行此命令(= 以管理员身份运行):

Get-Service ssh-agent | Set-Service -StartupType Automatic -PassThru | Start-Service
Run Code Online (Sandbox Code Playgroud)

(或者,如果您知道如何操作,也可以使用 GUI 执行此操作。它基本上使 ssh-agent 自动启动。)

Git 可选

为了让 Git 识别所有这些设置,您需要告诉 Git 使用内部 OpenSSH 而不是它自己的。(是的,在 Git 的情况下,现在有两个 OpenSSH 实例)

git config --global core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe
Run Code Online (Sandbox Code Playgroud)

(在此路径中使用正斜杠/或双反斜杠\\

通过这样做,Git(包括所有 Git 客户端)也可以访问存储的密码。

来源:https : //github.com/dahlbyk/posh-git/issues/640#issuecomment-435515055


Tho*_* S. 8

  • 确保安装了可选的 Windows 功能“OpenSSH Client”
  • 确保服务“OpenSSH Authentication Agent”至少具有“手动”启动类型(默认情况下:禁用)
  • 启动服务,例如通过调用 ssh-agent
  • 告诉它私钥文件: ssh-add <path-to-private-key-file>
  • 现在ssh user@server无需要求密码即可工作

不幸的是,我还没有找到让它在重启后记住私钥和密码的方法。