contact me at [email protected] link

Transferring files from a KVM guest (virtual machine) to its host system doesn’t have to be complicated. In this tutorial, we’ll use Python’s built-in HTTP server to move a file from guest to host using a simple wget command.

📝 Step 1: Prepare the File in the Guest VM

Start by creating or locating the file you want to transfer in the guest machine. In our example, we’re using a file named Hello.txt.

image

Make sure you navigate to the folder containing this file before running the server.


🚀 Step 2: Start Python’s HTTP Server

In the guest VM terminal, start an HTTP server in the directory containing the file:

python3 -m http.server 8000

This command starts a web server on port 8000, serving files in the current directory.

image

💡 Note: Ensure the host machine can access the guest over the network. Depending on your setup, you may need to configure bridged networking or adjust firewall rules.

Now, switch to the host machine and download the file using wget:

wget http://<guest_ip>:8000/data.txt

Replace <guest_ip> with the IP address of your guest. You can find it using:

ip a

if you are on linux or

ipconfig

if you are on windows.

image

I mistook the file names so you see a couple of errors in the console logs. I thought it would be a good idea to leave it there so you can see if that happens, check your file names too


📂 Step 3: Verify the File on the Host

After the download finishes, use the cat command to inspect the file:

cat Hello.txt

image

You should see the same content as on the guest machine.


✅ Summary

To recap, here’s the quick file transfer process:

Guest: Place the file and start the HTTP server with Python.

Host: Download the file using wget.

Host: Verify the file content using cat.

This method is ideal for quick, one-time transfers without needing to install additional software or set up shared folders.

ko-fi