How to share files between Linux and Windows
You will also need to have ssh-server set up and running on your Linux system. This allows it to support the client (Windows side) connection requests. If you don’t already have an ssh server set up, the following steps should work on Debian systems (Ubuntu, etc.). For Red Hat and related Linux systems, use similar commands: Note that if you are running a firewall such as ufw, you may have to open port 22 to allow the connections. Using the pscp command, you can then move files from Windows to Linux or vice versa. The syntax is quite straightforward with its “copy from to” commands. In the command shown below, we are copying a file from a user’s account on a Windows system to the /tmp directory on the Linux system. Moving the files from Linux to Windows is just as easy. Just reverse the arguments. The process can be made a little smoother and easier if 1) pscp is in your Windows search path and 2) your Linux system is in your Windows hosts file. If you install the PuTTY tools with the PuTTY installer, you will probably find that C:\Program files\PuTTY is on your Windows search path. You can check to see if this is the case by typing echo %path% in a Windows command prompt (type “cmd” in the search bar to open the command prompt). If it is, you don’t need to be concerned with where you are in the file system relative to the pscp executable. Moving into the folder containing the files you want to move will likely prove easier. Here’s the other little fix. With administrator rights, you can add your Linux system to the Windows host file (C:\Windows\System32\drivers\etc\hosts) and then use the host name in place of its IP address. Keep in mind that this will not work indefinitely if the IP address on your Linux system is dynamically assigned. Note that Windows host files are formatted like the /etc/hosts file on Linux systems — IP address, white space and host name. Comments are prefaced with pound signs. Keep in mind that lines in text files on Windows end with both a carriage return and a linefeed. The pscp tool will not remove the carriage returns to make the files look like Linux text files. Instead, it simply copies the files intact. You might consider installing the tofrodos package to enable you to use the fromdos and todos commands on your Linux system to adjust the files you are moving between platforms. Sharing folders is an entirely different operation. You end up mounting a Windows directory on your Linux system or a Linux directory on your Windows box so that both systems can use the same set of files rather than copying the files from one system to the other. One of the best tools for this is Samba, which emulates Windows protocols and runs on the Linux system. Once Samba is installed, you will be able to mount a Linux folder on Windows or a Windows folder on Linux. This is, of course, very different than copying files as described earlier in this post. Instead, each of the two systems involved will have access to the same files at the same time. More tips on choosing the right tool for sharing files between Linux and Windows systems are available here.
(CC BY-SA 2.0)sudo apt update
sudo apt install ssh-server
sudo service ssh start
sudo yum install openssh-server
sudo systemctl start sshd
Windows to Linux
C:\Program Files\PuTTY>pscp \Users\shs\copy_me.txt [email protected]:/tmp
[email protected]'s password:
copy_me.txt | 0 kB | 0.1 kB/s | ETA: 00:00:00 | 100%
Linux to Windows
C:\Program Files\PuTTY>pscp [email protected]:/tmp/copy_me.txt \Users\shs
[email protected]'s password:
copy_me.txt | 0 kB | 0.1 kB/s | ETA: 00:00:00 | 100%
Windows search path
C:\Users\shs>pscp copy_me.txt [email protected]:/tmp
[email protected]'s password:
copy_me.txt | 0 kB | 0.1 kB/s | ETA: 00:00:00 | 100%
Updating your Windows hosts file
C:\Users\shs>pscp copy_me.txt [email protected]:/tmp
[email protected]'s password:
hosts | 0 kB | 0.8 kB/s | ETA: 00:00:00 | 100%
# Linux systems
192.168.0.18 stinkbug
Those pesky line endings
Sharing folders between Windows and Linux
2-Minute Linux Tip: How to add and delete user accounts
2-Minute Linux Tips
2-Minute Linux Tip: How to add and delete user accounts