Transfer files and folders from Windows to Linux with WinSCP
Last Updated :
21 Apr, 2025
Introduction
When using Linux machines, either as a Virtual Private Server or as a Virtual Machine on your local computer, one of the major problems that people encounter is to transfer their files from their host (main) machine to the Linux machine. This problem is generally resolved by a file transfer protocol client such as WinSCP and FileZilla. In this article, we shall learn how to transfer files and folders from Microsoft Windows to a Linux machine using the WinSCP software. WinSCP is a File Transfer Protocol client for Microsoft Windows. As said, it uses the FTP (File Transfer Protocol) and SFTP (Secure File Transfer Protocol) protocols to transfer files from a Windows machine to any other machine (Linux in this case).
Prerequisites
- Windows machine with WinSCP installed.
- Linux machine connected to the internet.
Transferring Files/Folders from Windows to Linux using WinSCP
Once you have the prerequisites, you can follow the following steps to transfer files and folders using WinSCP.
Step 1: Get the Public IP Address of your Linux Machine
The first thing we need is the IP address of the target Linux machine. To get this, open a terminal and then, type the curl command in the terminal:
curl ipinfo.io/ip
Here, we are sending an HTTP request to the ipinfo.io/ip website which is a utility that returns the Public IP address of the client machine. Thus, you will get an IPv4 address on your machine.
Getting the public IP AddressStep 2: Allowing FTP in the firewall
Now, if you are using a firewall, it is important to allow the FTP in your firewall otherwise the WinSCP will not be able to connect to your machine. Generally, Linux machines use the ufw firewall. To allow the FTP service, type the following command in your Linux terminal.
ufw allow ftp
On success, you will see a message like the following:
Allowing FTP in the firewall.If you use some other firewall manager, use its corresponding commands to allow FTP.
Step 3: Connecting WinSCP to the Linux machine using the IP address
Now, open the WinSCP application on your windows machine. You will get a login prompt as follows:
WinSCP Login WindowHere, we will leave the File protocol to SFTP (Secure File Transfer Protocol), which means it will use port 22 for connecting to our Linux machine.
- In the hostname, enter the Public IP address of the Linux machine found in step 1.
- Then, enter the username which you want to connect using the machine and its password.
- (Optional) You can also save the connection settings if you desire.
Once all the fields are filled, click on 'Login' and you will be given a warning about whether you want to connect to the unknown target machine or not, like the following:
Warning for new connections.Allow it by clicking on the 'yes' button and it will be added to your trusted sources, which means that the next time you connect to this same machine, you will not be given such a warning again. Now, you have an active connection between the Windows and the target Linux machine. The WinSCP will now show you files from both your host machine and the remote Linux machine as well like below:
WinSCP Window after successful connectionOn the left split window, we have the host machine and on the right, we have the remote Linux machine.
Step 4: Copying Files and Folders from host to remote machine.
Now, to transfer any files/folders all you have to do is copy them from the right window and paste it in the left window.
To copy, right-click on a file or folder and click on copy to clipboard. We are taking the dummy_tranfer.txt file and dummy_folder directory for copying in this example.
Copying file to Clipboard
Then, in the remote machine, navigate to the folder you want to save the file/folder and right-click in it then, choose 'Paste From Clipboard'. In this example, we are copying the files into the /home/transfers/ directory in our Linux machine but, you are free to choose any directory However, be cautious of using the same later in the article as well.
Pasting the file/folder into the remote machineThe contents of the transfers folder will now look like:
Contents after successful transfer of files and folders.We have now successfully learned how to transfer files and folders from Windows to a Linux machine using WinSCP.
Note: There is no difference between transferring a file and a folder. You copy and paste them both in the same manner as shown above.
Step 5: Verifying the copied files
Now, to verify whether we have the files in our Linux machine, open a terminal on your Linux machine and type the following ls command:
ls <path to the directory used in WinSCP transfer (Step 4)>
This will give us the contents of the /home/transfers directory in which we copied our files.
Verifying TransferAs we can see, we have got the folder and the file we copied to our Linux machine.
Step 6: Closing the connection
Once you are done transferring files/folders, always close the connection properly as an unclosed connection might lead to unexpected errors sometimes. To close the connection, navigate to the Tabs option in the toolbar then, choose Disconnect Session. Now, the session is successfully logged out.
Closing the connection to a remote server.Conclusion
In this article, we learned how to fetch the public IP address of a Linux machine and then, use that IP address to set up a login session in WinSCP using the SFTP protocol to transfer files and folders. Then, we ended the tutorial by learning how to close the connection. The WinSCP provides other protocols, such as FTP, SCP, etc. to transfer files. It depends on the user's need to choose the appropriate one. However, in most general cases you would use the SFTP protocol, which is also recommended due to security reasons.
Similar Reads
How To Transfer File From Linux To Windows
Transferring files between Linux and Windows might seem tricky at first, especially if youâre new to working across different operating systems. Now, whether youâre sharing documents, moving project files, or backing up data, knowing how to transfer files between these two platforms is very importan
8 min read
Python - Move all files from subfolders to main folder
This article will discuss how to move all files from the subfolder to the main folder using Python. The approach is simple it is similar to moving files from one folder to another using Python, except here the main folder or parent folder of the subfolder is passed as the destination. Modules UsedOS
3 min read
How to Use Linux Commands in Windows with Cygwin
Cygwin is a collection of tools that provide a Linux Operating System's terminal look, feel, and some of its basic functionality for users of Windows OS who want to have a go over the basic commands of Linux without worrying about installing a Linux OS. To use this tool, first of all, we need to dow
3 min read
How to Zip and Unzip Files in Windows 11?
Zipping and unzipping files is a common task that helps reduce file size or bundle multiple files together for easier sharing. In this guide, we'll cover 3 easy methods to zip and unzip files in Windows 11 for free. Whether you're using built-in features or looking for quick ways to compress files i
4 min read
Python - Copy Files From Subfolders to the Main folder
In this article, we will discuss how to copy a file from the subfolder to the main folder. The directory tree that will be used for explanation in this article is as shown below: D:\projects\base | |__subfolder: | \__file.txt | |__main.py | Here we have a folder named "base" in which we have a folde
4 min read
Python - Move and overwrite files and folders
In this article, we will be learning on moving a collection of files and folders where there may be files/folders with the same name as in the source name in the destination. So that we may need to overwrite the existing destination file with the source file. The shutil.move() method is used to move
3 min read
How to use Kali Linux in Windows with WSL 2?
The Windows Subsystem for Linux lets developers run a GNU/Linux environment including most command-line tools, etc. direct on Windows, unmodified, without the overhead of an ordinary virtual machine or dual-boot system. Uses of WSL: Pick your preferred GNU/Linux distributions from the Microsoft Stor
5 min read
How To Rename Files And Folder In Amazon S3 ?
S3 stands for Simple Storage Service and is a widely used object storage service provided by Amazon Web Services. S3 offers unlimited storage to its users and also enables them to store any type of data, whether it be text, images, videos, executable files, tar files, etc. The reason why S3 is popul
3 min read
How to run Linux GUI apps on Windows with WSLg?
In this article, we will see how you can install your favorite Linux GUI application on your Windows PC/Laptop. For this, we will use WSLg. WSLg which stands for Windows Subsystem for Linux GUI is an open-source project that enables the support for running Linux GUI applications on Windows in a full
2 min read
How to Rename Files and Folders Using CMD?
Renaming files and folders is a fundamental task for system organization. While it's simple through the graphical interface, using CMD provides more flexibility, particularly for batch operations or when the interface is unavailable.In this guide, youâll master the ren (or rename) command, a built-i
4 min read