SSH 服务器和本地主机

SSH server and localhost

我尝试在 WSL 上安装 SSH 服务器,但没有成功。所以我在我的笔记本电脑上安装了我的 SSH 服务器,我尝试连接,它也不起作用。但它可以在我的 phone 上使用 4G 或一切都希望我的计算机在本地

我每次都会遇到这个错误,无论是使用 WSL Debian 还是 Windows :

ssh:连接到主机 localhost 端口 22:连接被拒绝

先检查这个OpenSSH Windows installation guide:

它包括一个网络配置:

Allow incoming connections to SSH server in Windows Firewall:

When installed as an optional feature, the firewall rule “OpenSSH SSH Server (sshd)” should have been created automatically.
If not, proceed to create and enable the rule as follows.

  • Either run the following PowerShell command as the Administrator:
    New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH SSH Server' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 -Program "C:\System32\OpenSSH\sshd.exe"
    
    Replace C:\System32\OpenSSH\sshd.exe with the actual path to the sshd.exe (C:\Program Files\OpenSSH\ssh.exe, had you followed the manual installation instructions above).
  • or go to Control Panel > System and Security > Windows Firewall1 > Advanced Settings > Inbound Rules and add a new rule for port 22.

然后你可以检查至少你的 SSH 守护进程是否可以接收任何东西。


OP SRP adds in the discussion:

The problem turned out to be other machine with same IP address as the server."
I cheated and it works: I used a VPN.