Skip to content

Quick data transfer between Linux and Windows

Scenario: you need to transfer some data between a Windows box (let's say, at least Windows XP) and a Linux box.
Sure, you could use sneakernet, let's say a USB stick or hard drive, and transfer it from one computer to the other. However, this requires that the boxes are physically close. Let's assume that the Windows computer is far enough that you are not able to travel to it (or you simply can't be bothered).
"Let's use the real network then", you'll say.
If you're brave, you could install Samba on the Linux box, and fumble with it until you get to the point where each computer can "see" the other usng SMB. This could take time, and furthermore it might sound like a lot of work especially if that is a one-off thing and you won't need it anymore.
Other solutions involve setting up some service like FTP on one box (needs a client on the other box), transfer the data via email (!), or other similarly involved set up. Again, a disproportionate amount of work; after all, you just want to transfer those damn files. It should be simple, shouldn't it?

What I'm suggesting is not the perfect solution, and I'm not claiming it will always be possible or available, but if the Windows box allows access via RDP (ie "Terminal services" in Windows speak), and you have an authorized account, you can use rdesktop to transfer your data. Yes, rdesktop isn't only to get a remote desktop. Let's look at some interesting options in the man page:

-r <device>
              Enable  redirection of the specified device on the client, such that it appears on the server.
              Note that the allowed redirections may be restricted by the server configuration.

              Following devices are currently supported:
       -r disk:<sharename>=<path>,...
              Redirects  a path to the share \\tsclient\ on the server (requires Windows XP or
              newer). The share name is limited to 8 characters.

So there we go. Let's try:

scooter $ ls /home/waldner/tmp
file1.txt  file2.txt
scooter $ rdesktop -u someuser -d somedomain -p - -g 1024x768 -a 16 -r disk:lshared=/home/waldner/tmp
Autoselected keyboard map en-us
Password: ********

Here is how "My Computer" looks like in the RDP Windows session:


Let's make sure it's really it:


Now you can easily transfer the data you want (in either direction). Note that other sessions running on the Windows box will not see the exported directory.