SSH connection failures from a Windows 10 host to an Ubuntu 22.04 guest typically stem from the Ubuntu user account lacking SSH access permissions or the sshd service rejecting password-based authentication for non-root users. To resolve this, verify that the target user is in the sudo group, ensure PasswordAuthentication yes is set in /etc/ssh/sshd_config, and confirm the SSH service is active and listening on port 22 within the virtual network.
Diagnosing the Connection Failure
When attempting to connect via SSH from Windows 10 using PowerShell or PuTTY, you may encounter errors such as "Connection refused," "Permission denied (publickey,password)," or timeouts. It is critical to distinguish between network-level failures and authentication failures. A "Connection refused" error usually indicates that the SSH daemon (sshd) is not running or is blocked by a firewall. Conversely, authentication errors suggest that the service is reachable but rejects the login credentials due to configuration restrictions.
First, ensure that the Ubuntu guest VM is powered on and has an active network interface. If you are using VirtualBox, check the network adapter settings. The most common configuration for host-guest communication is NAT or Bridged Adapter. In a NAT setup, port forwarding must be configured to map a host port to the guest's port 22. For bridged connections, the guest receives an IP address on your local network, allowing direct SSH access using that IP. You can find the guest's IP address by running ip addr show inside the Ubuntu terminal.
If the network path is clear, the issue likely lies within the Ubuntu system configuration. The term "non-admin account" in this context refers to the user account on the Ubuntu guest operating system, not the Windows host administrator account. Linux does not use the concept of "admin" accounts in the same way Windows does; instead, it relies on user groups and file permissions. By default, new user accounts may not have the necessary privileges to log in via SSH if specific configurations are missing.
Verifying SSH Service Status
Before modifying user permissions, confirm that the SSH server is installed and running on Ubuntu 22.04. Open a terminal in the Ubuntu guest and execute the following command:systemctl status ssh
If the service is inactive or failed, start it with:
sudo systemctl enable --now ssh
This command ensures that the SSH service starts automatically upon boot and begins immediately. Check the output for any error messages. If the service fails to start, review the logs using journalctl -u ssh for detailed diagnostics. Once the service is active, verify that it is listening on the correct port by running:
sudo ss -tlnp | grep :22
You should see a line indicating that sshd is listening on port 22. If no output appears, the service may not be bound to the correct interface, or another application might be occupying the port.
Configuring User Permissions and Authentication
The core issue often involves how Ubuntu handles authentication for standard users. By default, Ubuntu 22.04 may disable password authentication in favor of key-based authentication for security reasons. If you are trying to log in with a username and password, you must explicitly enable this option in the SSH configuration file. Edit the SSH daemon configuration file using a text editor with sudo privileges:sudo nano /etc/ssh/sshd_config
Search for the line containing PasswordAuthentication. It may be commented out with a hash symbol (#). Change it to:
PasswordAuthentication yes
Additionally, ensure that PermitRootLogin is set according to your security needs, though this affects root access rather than non-admin users. After making changes, restart the SSH service to apply them:
sudo systemctl restart ssh
Next, verify that the non-admin user account exists and has a valid shell. Run:
getent passwd username
Replace username with the actual account name. This command should return details about the user, including their home directory and shell path (typically /bin/bash). If the user does not exist, create it using:
sudo adduser username
Ensure the user is added to the sudo group if administrative privileges are required later, although this is not strictly necessary for SSH login:
sudo usermod -aG sudo username
Firewall and Network Considerations
Ubuntu comes withufw (Uncomplicated Firewall) enabled by default. Even if sshd is running, the firewall may block incoming SSH connections. Check the firewall status with:
sudo ufw status
If the status is active, allow SSH traffic by running:
sudo ufw allow ssh
This rule permits incoming connections on port 22. If you have customized the SSH port, replace ssh with tcp/[port_number]. After updating the firewall rules, test the connection again from the Windows 10 host.
For VirtualBox users, if you are using NAT networking, you must configure port forwarding. Go to the VM settings, select Network, then Advanced, and click Port Forwarding. Add a new rule mapping Host Port 2222 (or another available port) to Guest IP [IP Address] and Guest Port 22. From Windows, connect using:
ssh -p 2222 username@localhost
This approach bypasses potential IP conflicts and ensures that the host can reach the guest through the VirtualBox hypervisor interface.
Security Best Practices
While enabling password authentication resolves immediate connectivity issues, it exposes your system to brute-force attacks. It is highly recommended to switch to key-based authentication once connectivity is established. Generate an SSH key pair on your Windows 10 machine using PowerShell:ssh-keygen -t ed25519
Copy the public key to the Ubuntu guest using:
ssh-copy-id username@ubuntu_ip_address
After verifying that you can log in using the key, disable password authentication in /etc/ssh/sshd_config by setting PasswordAuthentication no. This significantly enhances the security posture of your virtual environment.
Understanding VirtualBox Linked Clones for Windows 10 provides additional context on managing VM states, which can help if you need to reset configurations quickly. Similarly, How to prevent Windows 10 from creating random new network adapters ensures stable network interfaces, reducing ambiguity when troubleshooting IP addresses.
Frequently Asked Questions
Why does SSH work with the root user but not my regular user?
By default, many Linux distributions restrict root login via SSH for security, but they may also misconfigure user permissions. Ensure your regular user has a valid shell assigned in/etc/passwd and that the home directory has correct ownership. If the user lacks a password set via passwd, password authentication will fail even if enabled.
Can I use SSH keys instead of passwords for non-admin users?
Yes, key-based authentication is the preferred method for all users, regardless of privilege level. It is more secure than passwords and avoids issues related to password complexity requirements or expired credentials. Set up keys by copying the public key from the Windows host to the~/.ssh/authorized_keys file on the Ubuntu guest.
What if I get a "Host Key Verification Failed" error?
This error occurs when the SSH client detects a change in the host key fingerprint, often after reinstalling the OS or changing network configurations. Remove the old entry from your Windowsknown_hosts file located at C:\Users\YourUsername\.ssh\known_hosts and reconnect to accept the new key.
Does disabling password authentication break access for non-admin users?
No, disablingPasswordAuthentication only affects password-based logins. Users who have properly configured SSH keys can still log in securely. However, if a user has not set up keys, they will be locked out. Always ensure key-based access is working before disabling passwords.
How do I check if my Ubuntu user account is locked?
A locked account prevents all login attempts. Use the commandpasswd -S username to check the status. If it shows "L" (locked), unlock it with sudo passwd -u username. This is distinct from permission issues and directly impacts SSH accessibility.