Operations 9 min read

Three Simple Ways to Transfer Files Between Host and Virtual Machine

Learn three practical methods—FTP, disk‑image tools, and SMB sharing—to move files between your host OS and a Linux virtual machine, complete with installation steps, configuration commands, and tips for both Windows and Linux environments.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Three Simple Ways to Transfer Files Between Host and Virtual Machine

Overview

File exchange between a host OS (typically Windows) and a Linux virtual machine can be achieved with three reliable approaches: FTP/SFTP using vsftpd, mounting the VM’s virtual disk with a disk‑image utility, and sharing a directory via Samba (SMB).

Method 1 – FTP/SFTP with vsftpd

Install the FTP server package and configure it to allow authenticated local users only.

sudo apt-get update
sudo apt-get install vsftpd

Edit /etc/vsftpd.conf (e.g., with sudo vi /etc/vsftpd.conf) and set the following options:

anonymous_enable=NO
local_enable=YES
write_enable=YES
local_root=/home/USERNAME/ftp
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list

Create the chroot list and the shared subdirectory:

sudo touch /etc/vsftpd.chroot_list
echo "USERNAME" | sudo tee -a /etc/vsftpd.chroot_list
mkdir -p /home/USERNAME/ftp/share
chmod 755 /home/USERNAME/ftp   # remove write permission for the FTP root if desired

Restart the service to apply changes: sudo systemctl restart vsftpd Clients such as FileZilla, Xftp, or the built‑in FTP module of MobaXterm can connect to ftp://VM_IP using the same username/password. For encrypted transfer, use SFTP (the OpenSSH server is typically already present; connect to sftp://VM_IP).

Method 2 – Mounting the Virtual Disk

When the VM is powered off, a disk‑image tool (e.g., DiskGenius, Ext2IFS, or the open‑source guestmount from libguestfs) can open the .vmdk or .qcow2 file and expose its filesystem to the host.

Launch the tool and choose “Open Virtual Disk”.

Select the VM’s disk file, for example G:\VMware\SysU16\Ubuntu16.04.vmdk.

The tool mounts the Linux partitions as read‑write volumes; you can then copy files to or from the share directory you created in Method 1.

On Windows 10, ensure that the BIOS/UEFI settings allow the tool to access ext* partitions; otherwise use a Linux host or the guestmount command line.

Method 3 – Samba (SMB) Share

Install Samba on the Linux VM and expose a directory. sudo apt-get install samba samba-common Create the shared directory and give it full permissions (adjust as needed for security):

mkdir -p /home/USERNAME/share
chmod 777 /home/USERNAME/share   # for testing; replace with stricter ACLs in production

Edit /etc/samba/smb.conf and append a share definition:

[share]
    path = /home/USERNAME/share
    browsable = yes
    writable = yes
    guest ok = no          # set to yes for password‑less access
    read only = no

Add a Samba user (the password can be the same as the Linux account):

sudo smbpasswd -a USERNAME
sudo smbpasswd -e USERNAME   # enable the account

Restart the Samba daemon: sudo systemctl restart smbd From a Windows host, open File Explorer and enter \\VM_IP\share. Supply the Samba credentials when prompted, or enable guest ok = yes to allow anonymous access.

Choosing a Method

Use FTP/SFTP for quick network‑based transfers, especially when the VM is running. Use the disk‑image approach for one‑off bulk copies while the VM is shut down. Use Samba when you need seamless Windows‑style file browsing and frequent bidirectional access.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

virtual machinefile transferFTPSMB
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.