Cannot connect to VM on Hyper-V using SSH

Saad Mateen 1 Reputation point


I am trying to connect my local machine to the VM on Hyper-V using SSH and I am getting an error. Here is the debug information when I tried sshing to the VM in PowerShell:

debug1: Reading configuration data C:\Users\myuser/.ssh/config
debug1: C:\Users\myuser/.ssh/config line 167: Applying options for *
debug3: Failed to open file:C:/ProgramData/ssh/ssh_config error:2
debug2: resolve_canonicalize: hostname (ip address) is address
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to (ip address) port 22.
debug2: fd 3 setting O_NONBLOCK
debug3: finish_connect - ERROR: async io completed with error: 10013, io:0000016536E04B90
debug1: connect to address (ip address) port 22: Permission denied
ssh: connect to host (ip address) port 22: Permission denied

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,427 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. MotoX80 32,441 Reputation points

    Are the OpenSSH services running on the VM and have you modified the sshd_config file to grant your account access?

    Is the firewall blocking port 22? On the client use Powershell to test access. "Test-Netconnection -Computername YourServerName -port 22",Rule%20for%20OpenSSH%20Server%20in%20Windows...%20More%20

  2. Jamie22 1 Reputation point

    You should have access without port 22 being open by opening the pfSense VM from your Hyper-V machine (assuming you are running pfSense from Hyper-V). If you cannot connect from another machine on the domain, take a look at your firewall rules to be sure port 22 is open between the two machines. If you are in a workgroup or simply behind a NAT somewhere, and the two subnets are different ( and for example), then your NAT must allow that port 22 access to flow.

    The Hyper-V NIC is also sensitive here. If the Hyper-V type for the NIC is internal only, it may restrict the way the remote path can be tagged from inside the domain. (assuming it is a domain or from inside the subnet)

    The three types are: External with a share for management (or with single-root I/O if the NIC supports it), then Internal and subsequently private.

    If it is private, they you can only access from the machine that holds the virtual machine or in this case from your Hyper-V machine.

    If it is internal, same as above but the machines that are between (I believe it means on the same subdomain) the VMs, can access the switch.

    0 comments No comments