Port 22 won't open even after enabling it on Windows Firewall settings

I'm currently trying to transfer file between my two local computer (laptop running Linux & PC Windows 10) by SHH using scp cmd, see here

I'm trying to transfer from Linux laptop to Windows PC.

But unfortunately, after creating a new inbound rule in Windows firewall settings, my port 22 is still not open.

I've checked that my port isn't open by using this command :

netstat -a -n

and

netstat -ab

I've also checked that my rule is enabled :

netsh firewall show config

and it returns :

22 TCP Activer Entrant SSH

So it's supposed to work, any clue on where the problem might come from ?

Could there be a conflict between user because I'm using WSL2 in order to run Ubuntu ? Like my username in the win shell different from the Ubuntu's one ?

UPDATE : disable Windows Firewall, do not allow connection on port 22.

UPDATE : ssh-server wasn't enabled on Windows machine

I've checked it by typing sudo service ssh statuson Linux shell from my Windows machine

so I follow instruction here

Then I knew that ssh was already installed and OpenSSH too using this cmd in PowerShell :

Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'

Returns :

Name : OpenSSH.Client~~~~0.0.1.0
State : Installed
Name : OpenSSH.Server~~~~0.0.1.0
State : Installed

Then I use these cmd :

# Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
# Install the OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

which both returns :

Path :
Online : True
RestartNeeded : False

then I've started OpenSSH server :

# Start the sshd service
Start-Service sshd
# OPTIONAL but recommended:
Set-Service -Name sshd -StartupType 'Automatic'
# Confirm the Firewall rule is configured. It should be created automatically by setup. Run the following to verify
if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) { Write-Output "Firewall Rule 'OpenSSH-Server-In-TCP' does not exist, creating it..." New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
} else { Write-Output "Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists."
}

Returns : Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists.

But then I've tried to connect to OpenSSH server using this cmd :

ssh username@servername

but I still won't be able to connect, it returns :

ssh: connect to host XX.XXX.X.XXX port 22: Connection timed out

I've made sure that I was running PowerShell as an administrator

I made sure my port 22 is now open :

netstat -a -n

returns :

TCP 0.0.0.0:22 0.0.0.0:0 LISTENING

then i've typed :

netstat -a -b -n

Returns :

 TCP 0.0.0.0:22 0.0.0.0:0 LISTENING [sshd.exe]

and

TCP [::]:22 [::]:0 LISTENING [sshd.exe]

Also, netsh firewall show config returns :

Domaine configuration du profil :
-------------------------------------------------------------------
Mode d’opération = Activer
Mode d’exception = Activer
Mode réponse multidiff/transmission = Activer
Mode de notification = Activer
Configuration des programmes autorisés pour le profil Domaine :
Mode Direction du trafic Nom / programme
-------------------------------------------------------------------
Configuration de port pour le profil Domaine :
Port Protocole Mode Direction du trafic Nom
-------------------------------------------------------------------
22 TCP Activer Entrant SSH
53 TCP Activer Entrant Realtek AP UDP Prot
1542 UDP Activer Entrant Realtek WPS UDP Prot
1542 UDP Activer Entrant Realtek WPS TCP Prot
Standard configuration du profil (en cours) :
-------------------------------------------------------------------
Mode d’opération = Activer
Mode d’exception = Activer
Mode réponse multidiff/transmission = Activer
Mode de notification = Activer
Configuration de service pour le profil Standard :
Mode Personnalisé Nom
-------------------------------------------------------------------
Activer Non Recherche du réseau
Configuration des programmes autorisés pour le profil Standard :
Mode Direction du trafic Nom / programme
-------------------------------------------------------------------
Activer Entrant audiorelay-tcp-private / C:\Program Files (x86)\AudioRelay\AudioRelay.exe
Configuration de port pour le profil Standard :
Port Protocole Mode Direction du trafic Nom
-------------------------------------------------------------------
22 TCP Activer Entrant SSH
53 TCP Activer Entrant Realtek AP UDP Prot
1542 UDP Activer Entrant Realtek WPS UDP Prot
1542 UDP Activer Entrant Realtek WPS TCP Prot
Configuration du journal :
-------------------------------------------------------------------
Emplacement du fichier = C:\Windows\system32\LogFiles\Firewall\pfirewall.log
Taille maximale de fichier = 4096 Ko
Paquets abandonnés = Désactiver
Connexions = Désactiver

File

C:\Windows\system32\LogFiles\Firewall\pfirewall.log

is empty.

UPDATE : after scratching my head a little more, I remembered that I currently use a "public" Ethernet connection provided by my university residency.

So I look for my default gateway IP by typing ipconfig then typed the address in a Chrome tab, but it doesn't worked

*then I remembered I was using uni internet

I go to their router setting page and look for my IP address and found out that it was neither the one I find when typing "what'is my IP" on the internet, nor the one who appears to be the default gateway in the console.

The IP declared by my uni router match the IPv4 in my network settings

But when I try to access this IP in a tab, I get : ERR_CONNECTION_REFUSED

Also, after figured out what my real IP was, I try again to connect to SSH with the IPv4 address. I get :

The authenticity of host 'xx.xxx.xxx.xx (xx.xxx.xxx.xx)' can't be established.
ECDSA key fingerprint is .
Are you sure you want to continue connecting (yes/no/[fingerprint])?

Typed yes, then :

Warning: Permanently added 'xx.xxx.xxx.xx' (ECDSA) to the list of known hosts.
Connection reset by xx.xxx.xxx.xx port 22

But it didn't ask for any password

So typed again ssh username@servername in order to connect, but I get ask for a password

I tried few ones and get Permission denied, please try again. for each except the last one where I get

Permission denied (publickey,password,keyboard-interactive).
8

1 Answer

After a little research I figured out that due to the fact I was using my university internet connection, my IP address was neither the one obtained by typing "what's my IP" on Google, nor my default gateway IP in the console.

According to the documentation on the service page of my uni router, it was my IPv4 address.

From there, I was able to send the right request in order to check if my port was open and to connect to SSH.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like