ssh from hyper-v host to linux guest not working. Works perfectly from other machines. How to fix?

%3CLINGO-SUB%20id%3D%22lingo-sub-2358679%22%20slang%3D%22en-US%22%3Essh%20from%20hyper-v%20host%20to%20linux%20guest%20not%20working.%20Works%20perfectly%20from%20other%20machines.%20How%20to%20fix%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2358679%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20a%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Elinux%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eguest%20with%20ssh%20enabled%20on%20a%20hyper-v%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ehost%3C%2FSTRONG%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDepending%20on%20the%20assigned%20vSwitch%20(Default%20or%20External)%2C%20I%20can%20ssh%20into%20linux%20from%20hyper-v%20host%20but%20not%20from%20other%20systems%2C%20or%20I%20cannot%20ssh%20into%20linux%20from%20hyper-v%20host%20but%20I%20can%20from%20other%20systems.%20In%20both%20cases%2C%20linux%20can%20access%20the%20internet.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3Ehost%3C%2FSTRONG%3E's%20IP%20address%20is%20192.168.1.204.%20Other%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Etest%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Emachine's%20IP%20address%20is%20192.168.1.7.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3ECase%201%3A%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3ELinux%20on%20Default%20vSwitch%2C%20assigned%20address%20172.23.174.5%3C%2FP%3E%3CUL%3E%3CLI%3Eping%20from%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ehost%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Elinux%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E-%20works%3C%2FLI%3E%3CLI%3Essh%20from%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ehost%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Elinux%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E-%20works%20(as%20the%20network%20172.23.160%2F20%20is%20directly%20connected%20to%20host%20by%20the%20Hyper-V%20setup)%3C%2FLI%3E%3CLI%3Eping%20from%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Etest%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Elinux%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E-%20will%20not%20work%2C%20since%20it%20is%20on%20another%20subnet%3C%2FLI%3E%3CLI%3Essh%20from%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Etest%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Elinux%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E-%20will%20not%20work%2C%20since%20it%20is%20on%20another%20subnet%3C%2FLI%3E%3CLI%3Eping%20from%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Elinux%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%208.8.8.8%20-%20works%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%3CSTRONG%3ECase%202%3A%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3ELinux%20on%20External%20vSwitch%2C%20assigned%20address%20192.168.1.214%3C%2FP%3E%3CUL%3E%3CLI%3Eping%20from%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ehost%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Elinux%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E-%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Eworks!!%3C%2FSTRONG%3E%3C%2FLI%3E%3CLI%3Essh%20from%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ehost%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Elinux%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E-%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3E%22Connection%20refused%22%20%26lt%3B%26lt%3B%26lt%3B---%20%3CFONT%20color%3D%22%23FF0000%22%3Ethis%20is%20the%20culprit%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FLI%3E%3CLI%3Eping%20from%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Etest%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Elinux%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E-%20works%3C%2FLI%3E%3CLI%3Essh%20from%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Etest%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Elinux%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E-%20works%3C%2FLI%3E%3CLI%3Eping%20from%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Elinux%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%208.8.8.8%20-%20works%3C%2FLI%3E%3C%2FUL%3E%3CP%3EObviously%2C%20I%20could%20go%20with%20Case%201%20(NAT)%20and%20use%20port%20forwarding%20(netsh%20interface%20portproxy..)%20on%20the%20host.%20But%20I'd%20rather%20like%20to%20understand%20why%20Case%202%20does%20not%20work.%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3EEspecially%20why%20ping%20from%20host%20to%20linux%20works%2C%20but%20ssh%20does%20not.%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20idea%20why%20this%20does%20not%20work%20and%20how%20to%20fix%20this%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDan%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2358679%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EHyper-V%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Elinux%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ENetworking%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Essh%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Contributor

 

I have a linux guest with ssh enabled on a hyper-v host.

 

Depending on the assigned vSwitch (Default or External), I can ssh into linux from hyper-v host but not from other systems, or I cannot ssh into linux from hyper-v host but I can from other systems. In both cases, linux can access the internet.

 

host's IP address is 192.168.1.204. Other test machine's IP address is 192.168.1.7.

 

Case 1: Linux on Default vSwitch, assigned address 172.23.174.5

  • ping from host to linux - works
  • ssh from host to linux - works (as the network 172.23.160/20 is directly connected to host by the Hyper-V setup)
  • ping from test to linux - will not work, since it is on another subnet
  • ssh from test to linux - will not work, since it is on another subnet
  • ping from linux to 8.8.8.8 - works

Case 2: Linux on External vSwitch, assigned address 192.168.1.214

  • ping from host to linux - works!!
  • ssh from host to linux - "Connection refused" <<<--- this is the culprit
  • ping from test to linux - works
  • ssh from test to linux - works
  • ping from linux to 8.8.8.8 - works

Obviously, I could go with Case 1 (NAT) and use port forwarding (netsh interface portproxy..) on the host. But I'd rather like to understand why Case 2 does not work. 

Especially why ping from host to linux works, but ssh does not.

 

Any idea why this does not work and how to fix this?

 

Dan

0 Replies