我正在尝试设置从Linux服务器到Windows计算机的无密码ssh路径。我目前在Windows计算机上运行MobaSSH。我可以从linux服务器ssh切换到Windows计算机,然后执行命令,但是我必须输入密码。
我在linux系统上创建一个公共RSA密钥,并使用WinSCP将文件复制到C:\ Users \ MyUserName \ .ssh文件夹,然后在Windows计算机上重新启动MobaSSh服务。
如果没有密码,它仍然不允许我输入。我在这里想念什么?任何帮助深表感谢。
答案 0 :(得分:-1)
OpenSSH可用于Windows 10,并且对我来说非常可靠。我可以始终从Linux机器连接而无需输入密码。这是设置方法。
升级到Windows 10版本1809或更高版本
powershell -c "(Get-Item 'HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion').GetValue('ReleaseID')"
;另请参见systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
(专业版与家庭版,内部编号)安装SSH客户端和服务器(以管理员身份; source)-在Windows PowerShell中:
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Start-Service sshd # remote login should be possible following this command
Set-Service -Name sshd -StartupType 'Automatic'
Get-NetFirewallRule -Name *ssh* # there should be a firewall rule named "OpenSSH-Server-In-TCP" # optional
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 # optional
scp ~/.ssh/id_rsa.pub administrator@remote_computer_name:'C:\ProgramData\ssh\administrators_authorized_keys' # if using an alternate method, ensure file is not UTF-16 encoded
icacls C:\ProgramData\ssh\administrators_authorized_keys /remove "NT AUTHORITY\Authenticated Users"
icacls C:\ProgramData\ssh\administrators_authorized_keys /inheritance:r
get-acl C:\ProgramData\ssh\ssh_host_dsa_key | set-acl C:\ProgramData\ssh\administrators_authorized_keys
Install-Module -Force OpenSSHUtils -Scope AllUsers # for: Repair-AuthorizedKeyPermission
cd C:\Users\...
ssh-keygen # create ~/.ssh
# add key(s) to ~/.ssh/authorized_keys
$ConfirmPreference = 'None'; Repair-AuthorizedKeyPermission -FilePath .ssh\authorized_keys
# if above fails, try ''%%Set-ExecutionPolicy Unrestricted -Scope CurrentUser%%''; see also https://github.com/PowerShell/Win32-OpenSSH/issues/1245#issuecomment-440388604