Simple File Transfer Workarounds For A Linux Hyper-V Guest
If you have successfully installed a Linux Lite 6.x operating system as a Windows 10/11 hyper-v guest just the fact that you did so means you will probably want some method of transferring files between your Windows 10/11 host and your Linux Lite 6.x hyper-v guest. There are a lot of options, as you can see from the links below, but most of them are either/or choices. Either you can access the Web but not transfer files between your host and guest, or you can transfer files between your host and guest but can’t access the web. The simplest exceptions to that general rule are Samba, WinSCP, using MS One Drive from Microsoft Edge, or using Google drive. The underlying code of hyper-v is nothing like quick emulation in Linux (qemu) where a guest Linux OS can always connect to a Linux OS host via SSH. I don’t like to use Samba remotely because using share folders is slow and awkward and doesn’t access all files on the user interface anyway, and you can’t change what your host shares remotely without running RDP, which I don’t like to do for many reasons (bandwidth, RAM tax, most hacked network protocol), and connecting to a WinSCP interface remotely also requires RDP. Neither Samba nor WinSCP are useful to me for remote file transfers. As a side observation I don’t find WSL2 particularly useful either, as I can run a fully installed Linux OS in hyper-v anyway, where having File Explorer Linux file recognition becomes unimportant and is awkward anyway.
https://www.altaro.com/hyper-v/transfer-files-linux-hyper-v-guest/
https://tunecomp.net/hyperv-virtual-machine-remote-access-lan-internet-external-switch/
https://www.itechtics.com/share-files-between-guest-host-hyper-v/
https://techbloggingfool.com/2021/02/28/hyper-v-nat-remote-access-to-windows-and-linux-virtual-machines/
Complicated huh? If you’re not an experienced Windows networking administrator I wouldn’t recommend any of the above solutions especially if you have a new or newer Windows machine that you don’t want to cause problems with. Just stick with the default switch. The simple way is better. If you have a Linux desktop to spare (you can even use a Raspberry PI) there’s no need to use any of the methods discussed in the links above, because you can enable decent up/down secure file transfers with any kind of operating system that can run an SSH server and a full featured SSH client like Remmina, on any home network and even work remotely. The advantage to this simple method is that once you know how to set it up you can basically set it up anytime and anywhere with any Linux desktop system. I use this method remotely when I need it in the field because it works universally and because I have access to a running Debian server in my office, another remote Debian server, and a Windows server when I want to use it as well, and on the go field configuration for secure and private file transfers is simple with this first method I’m going to discuss here. I often use a Remmina application x11 forwarded from my Debian office server to a remote Windows system that has an Xming server and an SSH server installed. See the link below:
https://www.dbts-analytics.com/sshw10ll5p1.html
However, because in this case I want to be able to securely and privately transfer files between my Windows 10/11 host and its Linux Lite 6.x system running in hyper-v; the simplest, most secure and most private option for file sharing to and from my Windows 10/11 host is to use the SSH server installed on my Windows 10/11 host. The problem with all of the methods discussed in the links above is that they all expose the Windows 10/11 host to a variety of host system vulnerabilities and even accidental system corruptions depending on which option you choose to use, and make remote work risky without a serious endpoint security application. Eventually Microsoft will give in and provide some sort of SFTP client interface for its archaic File Explorer, and rumors are that it is on the way, but the truth is I’ll probably still use Linux for my cross-platform connections. If you read through the first link above (altaro.com) method four describes how to set up a virtual transfer disk (VHDX). The basic network topography we’re going to use is similar, but far more useful since it is external rather than internal. Instead of a virtual transfer disk we’re going to substitute a running Linux Lite 6.x desktop machine with an SSH server/client and Remmina client installed on it.
Workaround 1: Use A Running Linux System As A Transfer Disk
I write mainly for Linux Lite users and many are new users. Currently the workaround described here is the simplest and most secure solution for new Linux Lite users who want to run Linux Lite in hyper-v and enable simple fast free and secure file transfers between their Windows host and Linux Lite hyper-v guest. This is a quick and easy result that uses GUI applications and very little effort in the terminal. Remmina SFTP client has a very nice GUI and is in Lite software, and works on most Linux systems and is really all we need for our connection to our hyper-v guest. What follows here is a simple workaround to pass through a second Linux Lite system (use a second running Linux system and SSH server/client as a substitute transfer disk) and transfer files over SFTP back and forth from a Windows hyper-v Linux guest. With the little script it runs quickly and sequentially.
Step 1) Install an SSH server to your Windows 10/11 machine.
Step 2) Install an SSH server from synaptic package manager and Remmina from Lite Software to the Linux Lite machine you wish to substitute for the transfer disk. Enable x11 forwarding on the SSH server. Set up an SFTP connection in Remmina to the SSH server on the Windows 10 machine hosting your hyper-v Linux Lite machine.
You can see here that I have already installed Remmina but below is the remove software page where it is listed just to show what the entry is.
Uncomment (remove the #) and change to: X11Forwarding yes
Set up an SFTP connection to your Windows machine.
Step 3) Install Remmina from Lite Software to your Linux Lite machine running in hyper-v. Set up an SFTP connection to your transfer disk substitute Linux Lite machine. Write and enable a shell script for sending files to your Windows 10/11 host and one for getting files from your Windows 10 host that uses Remmina.
It is plausible here to open an x11 forwarded instance of Remmina running on your transfer disk substitute Linux system on one desktop, and another native instance of Remmina running on your hyper-v Linux guest on another desktop. I just like the idea, especially working remotely where bandwidth can be a factor, of running a script that sequentially loads the Remmina instances one after the other. Writing two separate scripts, one for transfers to the Windows host, and one for transfers from the Windows host also simplifies the automation process. It’s simple enough to write the little scripts adapted to their specific purposes. Open up mousepad text editor on your Linux Lite hyper-v guest system and create the script with the syntax shown below:
#!/bin/bash
remmina 2>/dev/null
ssh -X trinidad@192.168.1.206 -p 54321 remmina 2>/dev/null
Save the file in Home as towinsftp.sh
Create a second file with the order reversed:
#!/bin/bash
ssh -X trinidad@192.168.1.206 -p 54321 remmina 2>/dev/null
remmina 2>/dev/null
Save the file in Home as fromwinsftp.sh
Open a terminal and enter: chmod +x ~/towinsftp.sh and when the prompt returns enter: chmod +x ~/fromwinsftp.sh and when the prompt returns your scripts will be executable. To run them when needed simply type in your terminal: ~/towinsftp.sh or ~/fromwinsftp.sh whichever one you need at the time and your Remmina instances will run in sequence instead of both opening at once.
You must quit the first Remmina for the second one to run because BASH runs commands in sequence. Quit Remmina in the way shown in the images below. First disconnect, then quit the first Remmina after your first file transfer and the second Remmina will open automatically immediately after. If you mess up between Remmina instances use the tray icon to quit.
One final note. If your Linux OS substitute transfer disk is a Linux system running wayland you will need to modify your script for the x11 forwarded instance of Remmina. See the link below and modify your script accordingly:
https://www.dbts-analytics.com/notesxfwdgb.html
Obviously when it comes to network connections Linux in general offers the simplest and best ways to secure a file transfer connection but of course there are always those who don’t understand this, or who have only one computer. If you are running Linux Lite in hyper-v and have only one machine there are a few other reasonable and secure (though less private) ways of accomplishing file transfers between your Windows host and your Linux Lite hyper-v guest.
Workaround 2: Install Microsoft Edge And Use MS One Drive
Workaround 3: Installing And Using Google Drive