Connecting Ubuntu 20.04 to Hyper-V using OpenSSH, not vsftpd

Abstract: Configure OpenSSH on Ubuntu 20.04 to enable secure remote management and file transfer from a Hyper-V host without using FTP.

Created: 2026-09-20 by
Setting up an OpenSSH connection between Ubuntu 20.04 and Microsoft Hyper-V provides a secure, encrypted alternative to legacy FTP protocols like vsftpd. This method allows you to manage your virtual machine via command line with strong authentication and data integrity. By configuring the SSH daemon correctly on the guest OS and adjusting network settings in Hyper-V Manager, you can establish a reliable remote access channel that supports file transfers, remote administration, and automated scripting tasks without exposing sensitive credentials over unencrypted networks.

Prerequisites for Secure Remote Access

Before configuring the software components, ensure that both the host machine running Windows Hyper-V and the Ubuntu 20.04 virtual machine are properly initialized. The Ubuntu VM must have a static IP address assigned within its internal network or through the DHCP server of your router if bridged. A static IP prevents connection drops caused by lease renewals changing the address dynamically. Additionally, verify that the OpenSSH server package is installed on the Ubuntu instance. If it is missing, install it using sudo apt update && sudo apt install openssh-server. This package includes the sshd daemon required to listen for incoming connections. You should also confirm that the Hyper-V virtual switch is configured appropriately. For most development and testing scenarios, an Internal Virtual Switch or a Private Virtual Switch works well because it isolates the VM from external networks, reducing attack surfaces. However, if you need internet access from the VM, a External Virtual Switch bound to your physical network adapter is necessary. Ensure that the firewall on the Windows host allows inbound traffic on port 22, which is the default SSH port. You can create an inbound rule in Windows Defender Firewall to permit TCP traffic on this port specifically for the Hyper-V management process.

Configuring the SSH Daemon on Ubuntu

The core of the setup involves modifying the configuration file for the SSH daemon located at /etc/ssh/sshd_config. Open this file with a text editor such as nano or vim using sudo privileges. First, locate the Port directive and ensure it is set to 22 unless you have a specific reason to use a non-standard port. Changing the port adds a minor layer of obscurity but does not replace proper security measures. Next, find the PermitRootLogin setting. It is highly recommended to set this to no or prohibit-password to prevent direct root access via password, forcing you to log in as a standard user and escalate privileges when needed. Disable password authentication entirely by setting PasswordAuthentication no. This forces the use of key-based authentication, which is significantly more secure against brute-force attacks. Generate an SSH key pair on your local machine if you do not have one already, using ssh-keygen -t ed25519. Copy the public key to the Ubuntu VM using ssh-copy-id user@ip_address. This command appends your public key to the ~/.ssh/authorized_keys file on the remote server. After making these changes, restart the SSH service with sudo systemctl restart sshd to apply the new configuration. Test the connection from your local machine to ensure you can log in using your key without being prompted for a password.

Establishing the Connection from Hyper-V Host

Once the SSH server is configured and secured, you can initiate the connection from your Windows host. Open PowerShell or Command Prompt and type ssh username@ubuntu_ip_address. Replace username with your actual Ubuntu username and ubuntu_ip_address with the static IP you assigned earlier. If the connection succeeds, you will see a welcome message and a shell prompt, indicating that you are now remotely controlling the Ubuntu 20.04 instance. This method is vastly superior to using vsftpd because SSH encrypts all transmitted data, including commands and file contents, protecting them from eavesdropping on the local network. For advanced usage, consider enabling X11 forwarding if you need to run graphical applications from the Ubuntu VM on your Windows desktop. Add X11Forwarding yes to the sshd_config file and restart the service. On the Windows side, you will need an X server like VcXsrv installed. Then, connect using ssh -X username@ip_address. This allows you to launch GUI tools remotely while keeping the processing power on the VM. This approach integrates seamlessly with other Linux administration tasks, allowing you to manage services, edit configurations, and monitor system logs directly from a single terminal window.

Troubleshooting Common Issues

If you encounter connection timeouts, check the virtual switch settings in Hyper-V Manager. Ensure that the VM is connected to the correct virtual network adapter. Sometimes, disabling and re-enabling the network adapter inside the Ubuntu guest OS can resolve temporary connectivity glitches. Use sudo ip link set eth0 down followed by sudo ip link set eth0 up to reset the interface. If you receive permission denied errors, verify that your private key has the correct permissions. On Linux hosts, keys must be readable only by the owner (chmod 600 ~/.ssh/id_ed25519). On Windows, ensure that PuTTY or OpenSSH client is pointing to the correct key file. Another common issue arises when the SSH service fails to start after configuration changes. Check the status of the service using sudo systemctl status sshd. Look for any error messages related to syntax errors in the sshd_config file. You can test the configuration validity before restarting by running sudo sshd -t. If this command returns no output, the configuration is syntactically correct. If it reports errors, fix them in the config file and try again. For persistent issues, consult the system logs at /var/log/auth.log for detailed authentication failure reasons.

Enhancing Security and Performance

To further harden your SSH connection, consider implementing fail2ban. This tool monitors log files for repeated failed login attempts and temporarily bans the offending IP addresses. Install it with sudo apt install fail2ban and enable it to protect your SSH service automatically. Additionally, disable unused authentication methods in sshd_config by setting KerberosAuthentication no and GSSAPIAuthentication no. These features can cause delays during login if they are not required in your environment. Disabling them speeds up the connection process and reduces the attack surface. Regularly updating the OpenSSH package is crucial for maintaining security. Run sudo apt upgrade openssh-server periodically to patch known vulnerabilities. Keep your Windows host updated as well to ensure compatibility with the latest SSH protocols. While vsftpd might seem simpler for basic file transfers, it lacks the robust encryption and flexible control provided by SSH. By sticking with OpenSSH, you gain a versatile tool that handles everything from simple file copies to complex remote deployments securely.

Frequently Asked Questions

Can I use SSH to transfer files instead of FTP?

Yes, you can use SCP or SFTP clients to transfer files securely over the SSH connection. Commands like scp local_file user@ip:/remote_path allow you to copy files without installing additional server software. This method is faster and more secure than traditional FTP because it uses the existing encrypted tunnel.

Why is my SSH connection slow on Ubuntu 20.04?

Slow connections are often caused by GSSAPI authentication attempts timing out. Setting GSSAPIAuthentication no in sshd_config usually resolves this issue immediately. Another factor could be DNS resolution delays; adding UseDNS no to the configuration can speed up the handshake process.

How do I allow multiple users to connect via SSH?

By default, any user account on the Ubuntu system with a valid password or SSH key can connect. To restrict access, you can use the AllowUsers directive in sshd_config to specify a whitelist of usernames who are permitted to log in. This adds an extra layer of control over who can access the system remotely.

Is it safe to leave SSH running on a virtual machine?

It is safe if you follow best practices such as disabling root login, using key-based authentication, and keeping the software updated. Using a firewall to restrict access to specific IP addresses further enhances security. Avoid exposing the SSH port directly to the public internet without additional protective measures like fail2ban.

What happens if I forget my SSH key passphrase?

If you lose the passphrase for your private key, there is no way to recover it. You will need to generate a new key pair and update the authorized_keys file on the server. To avoid this, store your private keys in a secure password manager or use a hardware security key for added protection.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More