Resolve SSH connection timeouts between Windows and Ubuntu 20.04 by verifying virtual network adapter settings, ensuring the SSH service is active, and checking firewall rules on both host and guest systems. This guide addresses common configuration errors that prevent successful remote access.
Verify Virtual Network Adapter Configuration
The most frequent cause of connectivity issues in virtualized environments stems from incorrect network adapter modes. When running an Ubuntu 20.04 virtual machine (VM) on a Windows host, the virtualization software must bridge or NAT traffic correctly to allow the host to reach the guest. If you are using Hyper-V, VMware, or VirtualBox, ensure the network adapter is set to "NAT" or "Bridged" mode rather than "Host-only," unless you have explicitly configured static routes for that specific interface. For NAT configurations, the VM receives an internal IP address assigned by the hypervisor's DHCP server. You must identify this IP address within the Ubuntu terminal using theip addr show command. Look for the inet entry under your primary network interface, typically named eth0 or ens33. Once you have the correct IP, attempt to ping it from the Windows Command Prompt or PowerShell using ping <ubuntu_ip>. If the ping fails with "Request timed out," the network layer is blocked, and you should check your hypervisor's network settings. For bridged mode, the VM acts as a distinct device on your local LAN, so ensure its IP does not conflict with other devices and that your physical router allows inter-device communication.
Ensure SSH Service is Running and Listening
Even with perfect network connectivity, the SSH daemon (sshd) may not be running or listening on the expected port. By default, Ubuntu uses port 22, but misconfigurations can change this. First, verify the status of the service by running sudo systemctl status ssh in the Ubuntu terminal. If the service is inactive or failed, start it immediately with sudo systemctl start ssh and enable it to start on boot using sudo systemctl enable ssh.
Next, confirm that the service is actually listening for incoming connections. Use the command sudo netstat -tulpn | grep :22 or ss -tulpn | grep :22 to view open ports. You should see a line indicating that sshd is bound to 0.0.0.0:22 or :::22. If it shows only 127.0.0.1:22, the service is restricted to localhost connections, which prevents external hosts like your Windows machine from connecting. To fix this, edit the SSH configuration file located at /etc/ssh/sshd_config. Find the line starting with ListenAddress and comment it out or change it to 0.0.0.0. After making changes, restart the service with sudo systemctl restart ssh.
Check Firewall Rules on Ubuntu
Ubuntu 20.04 comes with UFW (Uncomplicated Firewall) enabled by default, which often blocks incoming SSH traffic if not properly configured. To check the current status, runsudo ufw status verbose. If the status is "active," look for a rule allowing port 22. If no such rule exists, you must add it manually using sudo ufw allow ssh or sudo ufw allow 22/tcp.
If you have previously allowed SSH from specific IPs, ensure your Windows host's IP address is included in the allow list. Sometimes, users mistakenly deny all traffic before adding exceptions. In such cases, you may need to reset the rules using sudo ufw reset and re-apply the necessary allowances. Remember that changing firewall rules requires immediate effect; there is no reload step for UFW. Test connectivity again after enabling the rule. If you are using a custom port, replace 22 with your chosen port number in all commands above.
Troubleshoot Windows Host Firewall and Routing
While less common, the Windows host itself might block outbound connections on port 22 due to strict corporate policies or personal firewall settings. Although rare, some security suites intercept outgoing SSH attempts. Try disabling Windows Defender Firewall temporarily to test if it is the culprit. If connectivity succeeds, create an outbound rule to allow TCP traffic on port 22. Additionally, consider potential routing conflicts if your Windows machine has multiple network interfaces, such as Wi-Fi and Ethernet. Ensure that the route table directs traffic to the VM correctly. You can view routes withroute print in Windows. If you are experiencing intermittent timeouts, refer to our guide on Troubleshooting SSH WSL Machine: Can't Connect to Localhost for insights into how different virtual adapters interact with the host OS. Another related issue involves key management; if you receive authentication failures instead of timeouts, check SSH from Windows system picking up wrong public key from known hosts file to resolve identity mismatches.
Test Connection with Verbose Output
When standard pings and basic SSH attempts fail, use the verbose flag to diagnose the exact point of failure. Runssh -v user@<ubuntu_ip> from your Windows terminal. The output will detail each step of the handshake process. Look for lines indicating "Connection refused" (service not running), "No route to host" (network path broken), or "Operation timed out" (firewall dropping packets). This detailed log is invaluable for pinpointing whether the issue lies at the network layer, transport layer, or application layer.
Frequently Asked Questions
Why does SSH work on LAN but not from my Windows host?
This usually indicates a virtualization network isolation issue. Ensure your VM's network adapter is not set to "Internal" or "None" mode, which restricts communication to the guest OS only. Switching to NAT or Bridged mode typically resolves this discrepancy by exposing the VM to the host's network stack.How do I find the IP address of my Ubuntu VM if DHCP fails?
If DHCP does not assign an IP, you can configure a static IP in the Netplan configuration files located in/etc/netplan/. Edit the YAML file to define a static address, gateway, and DNS servers, then apply the changes with sudo netplan apply. This ensures consistent connectivity regardless of DHCP availability.
Can I use PuTTY instead of OpenSSH client on Windows?
Yes, PuTTY is fully compatible with Ubuntu's SSH server. However, ensure you specify the correct hostname (IP address) and port (default 22) in the PuTTY session configuration. If you encounter connection timeouts in PuTTY, the underlying network or firewall issues remain the same as those affecting the native Windows SSH client.What if I changed the default SSH port?
You must specify the new port when connecting using the-p flag, for example, ssh -p 2222 user@<ip>. Additionally, ensure that both the UFW firewall on Ubuntu and any intermediate routers allow traffic on this non-standard port. Failure to update these rules results in silent packet drops.