Home > Net >  SSH connection reset/refused
SSH connection reset/refused

Time:02-18

First,please execuse my poor English.

Problem

I'm trying to download openssh on Widnows 7. I have a Arch_Linux machine and a Widnows 7 machine(Virtual Box) .I want to ssh connect to the windows 7 using ssh on Linux.

PS:

There are two accounts on Windows 7 User:whoami,it's passowrd is 123.And joe ,but he doesn't have passowrd. There are a account on my linux.User:kevin,it's passowrd is 123. My Linux machine IP adress is 192.168.1.43.My Windows7 machine IP adress is 192.168.1.54.

I don't know why if I type ssh [email protected] on Windows7.It will return ssh connect to host 192.168.1.43 port 22: Connection refused. If I type ssh [email protected]. It will return Connection reset by 192.168.1.54 port 22.If I type ssh [email protected].It still return Connection reset by 192.168.1.54 port 22. enter image description here

My Steps

I download the openssh on Windows 7 use these setps.

  • 1.Download the Openssh-Win32 form https://github.com/PowerShell/Win32-OpenSSH/releases/tag/V8.6.0.0p1-Beta.

    1. I extracted it to C:\Program Files\
    1. I add its path to the System PATH.
    1. I type powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1
    1. I type net start sshd
  • 6.I type sc config sshd start=auto

Now,I can use the ssh on my Windows 7 machine.

My guess

I think the problem is the firewall caused. But I closed the windows firewall.It still can't work.

CodePudding user response:

Add on Windows machine firewall rule, which allow outbound ssh traffic

netsh advfirewall firewall add rule name=ssh dir=out action=allow protocol=TCP localport=22

Show your iptables configuration iptables –L

And add iptables (Linux firewall) rules at sshd side (Linux machine).

iptables -A INPUT -p tcp --dport ssh -s <your_windows_machine_ip-address> -m state --state NEW,ESTABLISHED -j ACCEPT

iptables -A OUTPUT -p tcp --sport 22 -d <your_windows_machine_ip-address> -m state --state ESTABLISHED -j ACCEPT

Then save changes in iptables configuration in Debian-based distro sudo /sbin/iptables-save OR in RH/CentOS /sbin/service iptables save Show your iptables configuration again iptables –L

CodePudding user response:

@ashed

I do that like you said. But it still can't work.

Maybe is my problem. enter image description here

CodePudding user response:

  1. You can use "ssh -vvv [user name]@[ip]" to get more information for connection failed.
  2. You can use "nc -z [ip] [port]" to make sure your ethernet connectivity.
  3. Check your sshd_config, if there are some configurations denied user connection.
  • Related