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 Address
Step 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 Window
Here, 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 connection
On 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 machine
The 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 Transfer
As 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.
Sometimes you need to transfer files over a network. There are lots of file sharing services out there, but most require that you send your file to the Internet. This seems like a long way to go (not to mention the privacy concerns) when two computers are right beside each other, or at least in the same building. The open source WinSCP utility makes it quick and easy to transfer a file or a folder of files over the network from your Windows computer to your Linux computer.
IP address
Before you can make the transfer, you must know the IP address or fully-qualified domain name of the destination computer. Assuming it’s a computer on your same network, and that you’re not running a DNS server to resolve computer names, you can find the destination IP address using the ip command on the Linux machine:
[linux]$ ip addr show | grep 'inet '
inet 127.0.0.1/8 scope host lo
inet 192.168.1.23/24 brd 10.0.1.255 scope global noprefixroute eth0
In all cases, 127.0.0.1 is a loopback address that the computer uses only to talk to itself, so in this example the correct address is 192.168.1.23. On your system, the IP address is likely to be different. If you’re not sure which is which, you can try each one in succession until you get the right one (and then write it down somewhere!)
Alternatively, you can look in your router’s settings, which list all addresses assigned over DHCP.
Firewalls and servers
The WinSCP command uses the OpenSSH protocol, so your Linux computer must be running the OpenSSH server software, and its firewall must allow SSH traffic.
If you’re not sure whether your Linux machine is running SSH, then run this command on the Linux machine:
[linux]$ sudo systemctl enable --now sshd
To ensure your firewall allows SSH traffic, run this command:
[linux]$ sudo firewall-cmd --add-service ssh --permanent
For more information on firewalls on Linux, read Make Linux stronger with firewalls.
Using WinSCP
WinSCP is an open source SSH file transfer application for Microsoft Windows. To use it, you first must download and install it.
Once you’re installed it, open WinSCP and select the SCP option in the File Protocol field.
Add the IP address or DNS name of your Linux computer in the Host name field, and enter 22 in the Port number field. Enter you user name and password for the Linux computer, and then click the Login button at the bottom of the WinSCP window.
Image by:
(Paul Laubscher, CC BY-SA 4.0)
Verify that you are authenticated to the Linux computer. Upon success, your Linux computer’s IP address or DNS name appears at the top of the window.
Image by:
(Paul Laubscher, CC BY-SA 4.0)
Now you can drag and drop a file (I used winscp-test.txt as an example) from the left Windows pane to the destination Linux computer pane on the right, and the file transfers.
Image by:
(Paul Laubscher, CC BY-SA 4.0)
Alternatively, you can right-click on a file in the left pane and upload it to the remote destination in the right pane.
Image by:
(Paul Laubscher, CC BY-SA 4.0)
Verify the copy
Open a Linux terminal and use the ls command to view the transferred winscp-test.txt file. In my example, it appears in my home directory, /_home_/sysadmin.
$ ls
Desktop
Documents
Downloads
Music
Pictures
pscp-test.txt
[...]
You’ve successfully transferred a file from a Windows computer to a Linux computer over the network!
Of course, you can use the same technique as above to transfer files and folders from a Linux computer to a Windows computer.
Remote copying
With the power of the open source WinSCP application, you have access to any computer in your house or workplace, to servers you have accounts on, and even mobile, edge, and Internet of Things devices. Use this great tool to transfer files as easily as you would copy a file from one local directory to another!
This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.
Transferring files between Windows and Linux can sometimes be confusing, but do not worry. There is an easy tool called WinSCP that makes it simple. This guide will explain everything step by step in an easy-to-understand way, so even beginners can use it without trouble.
What is WinSCP?
WinSCP is a free program for moving files between a Windows and a Linux computer. It provides a simple graphical interface that makes transferring files easy, even for those who are not very familiar with technical tools. Instead of using complex command lines, you can just drag and drop files between the two systems. This makes it a great choice for beginners who can transfer data without any problems.
Read More: How to integrate the Windows Subsystem for Linux with Windows 11?
Why Use WinSCP?
WinSCP is a popular choice for file transfers because it offers several useful features. First, it has a simple and easy-to-use interface, making it easy to find and move files. Second, it supports different file transfer methods like SFTP, FTP, and SCP, so you can choose the one that best suits your needs. Another key feature is file synchronization, which helps keep your files updated between both systems. Most importantly, WinSCP ensures secure transfers, so your files are safe during the process.
How to Download and Install WinSCP?
To start using WinSCP, you first need to install it on your Windows computer. Follow these simple steps to download and install it properly.
Steps to Download
- Go to the official WinSCP website.
- Click on the download button to get the latest version.
- Wait for the file to finish downloading before opening it.
Steps to Install
- Open the downloaded file by double-clicking on it.
- Follow the on-screen instructions to proceed with the installation.
- When given the option, choose Typical Installation. This is recommended for beginners as it includes all the necessary features.
- After installation is complete, open WinSCP. You will see a login screen where you can set up your connection to a Linux computer.
Read More: Setup to Install Linux Mint: A Comprehensive Guide
Connecting WinSCP to Your Linux Computer
Before transferring files, you need to ensure your Linux computer is ready to accept connections. This requires enabling SSH, which allows secure communication between Windows and Linux.
Setting Up SSH on Linux
Open the Linux Terminal.
Type the following command and press Enter to install the SSH server:
sudo apt-get install openssh-server
After the installation is complete, start the SSH service by typing:
sudo systemctl start ssh
To check if SSH is running correctly, use this command:
sudo systemctl status ssh
If SSH is running, you will see a message confirming it.
Setting Up WinSCP
- Open WinSCP on your Windows computer.
- In the Login Screen, enter the following details:
- File Protocol: Choose SFTP.
- Host Name: Enter your Linux computer’s IP address (find it by running ip addr in the Linux Terminal).
- Port Number: Type 22, which is the default SSH port.
- User Name: Enter the username of your Linux computer.
- Password: Type your Linux user password.
- Click Save to store these settings so you don’t have to enter them every time.
- Click Login to connect to your Linux computer.
How to Transfer Files Using the Drag and Drop Method?
Once you have connected successfully, you will see two sections in WinSCP:
- The left side shows files on your Windows computer.
- The right side shows files on your Linux computer.
To Move Files Between Windows and Linux
- To upload a file from Windows to Linux, simply drag the file from the left panel (Windows) to the right panel (Linux).
- To download a file from Linux to Windows, drag the file from the right panel (Linux) to the left panel (Windows).
This drag-and-drop method makes transferring files very simple and does not require any complicated commands.
How to Sync Folders Between Windows and Linux?
Sometimes, you may need to keep a folder updated on both your Windows and Linux computers. Instead of manually transferring files one by one, you can use the Sync feature in WinSCP.
- Locate the folder you want to synchronize.
- Right-click on the folder and select Synchronize.
- Choose the synchronization options, such as whether you want to update only newer files or all files.
- Click OK to start the synchronization process.
This feature ensures that both systems always have the latest version of your files.
- Use Keyboard Shortcuts: Learning shortcuts can save time when navigating and transferring files.
- Customize the Layout: WinSCP allows you to adjust its settings for easier navigation.
- Check the Transfer Mode: WinSCP lets you choose between Binary Mode (preserves files exactly as they are) and Text Mode (adjusts line endings for compatibility between Windows and Linux). If you are transferring text files, use Text Mode to prevent formatting issues.
Conclusion
WinSCP is an excellent tool for transferring files between Windows and Linux computers. With its user-friendly interface and powerful features, it makes file transfers simple and secure. By following the steps in this guide, you can easily set up WinSCP, connect to your Linux computer, and start moving files without any technical difficulties. Whether you are a beginner or someone looking for a convenient file transfer solution, WinSCP is the perfect choice!
In the world of computing, the seamless transfer of files between different operating systems is essential for efficient collaboration and productivity. When it comes to transferring files from Windows to Linux, WinSCP (Windows Secure Copy) emerges as a reliable and user-friendly solution. In this step-by-step guide, we will walk you through the process, making it easy for you to transfer your files effortlessly and securely between Windows and Linux.
What is WinSCP?
WinSCP (Windows Secure Copy) is a popular open-source file transfer application that allows users to securely transfer files between a local Windows computer and a remote Linux server or vice versa. It supports various protocols such as SCP (Secure Copy Protocol), SFTP (SSH File Transfer Protocol), and FTP (File Transfer Protocol) over TLS/SSL. WinSCP provides a graphical user interface (GUI) that makes it easy for users to navigate and manage their files during the transfer process. It offers features such as drag-and-drop functionality, synchronized browsing, and integration with popular text editors. WinSCP also supports automation through scripting and supports secure authentication methods like SSH keys and password encryption. Overall, WinSCP is a reliable and user-friendly tool for transferring files between Windows and Linux systems securely.
Steps to Transfer Files Between Windows and Linux Using WinSCP
Prerequisites
Verify Your Remote Linux Server is Ready
If you have ordered one from Database Mart, you will receive an email containing the information of your VPS, including server IP and login credentials.
1. Download and Install WinSCP
First, we need to download the WinSCP tool on the local Windows system. Search for WinSCP official download address in the browser, and then click into the page to download the latest WinSCP.
Once the file is downloaded, double-click the .exe file to install the software. Then, select the Install for all users option.
After reading through the agreement, click «Accept» to proceed to the next step.
For the setup type, just select the default and recommended one — Typical installation. Then, click «Next.»
Choose the user interface you prefer. You can also choose the default option here and continue to the next step.
This step is to confirm your choices in the above steps. If you would like to change any of the settings, click back. Otherwise, click «Install» to initiate the installation.
When you reach this page, you’ve successfully installed WinSCP. Now, you can click «Finish» to open WinSCP.
2. Connect to Linux Server
Before the file transfer, we need to first provide login information so we can connect to the Linux server. We can save the connection information so that we can directly log in without having to enter the connection information every time. Fill in the following information.
File Protocol: Select the default value — SFTP.
Host name: The IP address of the remote Linux server.
Port: It usually is the default port 22. If the SSH port is modified to a custom ports, please fill in the custom one.
User Name: The username is about to log in to the Linux server.
Password: The password for the user.
Finally click the Save button below.
Name this connection file for easy identification later. Then, click OK.
From the left panel, you can see that the connection file has been saved. Finally, we click «Login».
Decide if you would like to add the host key to a cache. If you trust the host, press Yes.
You are required to enter the password again here. Simple type in the password and click OK.
3. Transfer Files Between Windows and Linux
After logging in, we can see that our local files are on the left and the files of the remote Linux server is on the right. Right-click the file or folder you want to transfer from the left, then click Upload.
Here we confirm the directory we will upload the files or folders to. As we logged as an administrator, we are only allowed to transfer files to the administrator directory, but the root directory.
It is also possible to download the files under the administrator directory to your local computer. Right-click the file or folder you want to download, and select Download.
Also, determine the path of the to-be-downloaded file and click OK.
Conclusion
By following the steps provided in this article, you will be able to easily transfer files from your Windows local system to a remote Linux server using WinSCP. This will increase your productivity and simplify day-to-day file interactions.
If you’re a Windows user and need to transfer files to or from a Linux machine, WinSCP is a powerful tool to have in your arsenal. It’s an open-source, free SFTP, SCP, and FTP client for Microsoft Windows that enables secure file transfer between a local and remote computer.
In this blog, we’ll walk you through the steps to connect your Windows system to a Linux server using WinSCP.
Step 1: Install WinSCP
The first step is to get WinSCP installed on your system. It’s quite simple. Head to the official WinSCP downloads page and download the latest version of the software. Once downloaded, follow the installation prompts to install WinSCP on your machine.
Step 2: Launch and Configure WinSCP
After installing, launch WinSCP. The “Login” dialog box will appear. Here is where you’ll enter the details of the Linux server you want to connect to.
Hostname: [your server’s IP or domain]
Port number: 22 (the default for SFTP)
Username: [your username]
Password: [your password]
Remember to replace the brackets and their content with your actual server details. For the file protocol, you can select SFTP (SSH File Transfer Protocol).
Step 3: Establish the Connection
Once you’ve entered the details, click on the Login button to establish a connection. For the first connection, WinSCP will ask if you trust the host you’re connecting to. Click on Yes.
If the details were correct, you should be connected to your Linux server. You’ll find the Linux directory on the right side of the interface and your local files on the left. Simply drag and drop files to transfer them.
Conclusion
That’s it! Now you know how to connect to a Linux server from a Windows machine using WinSCP. It’s a simple yet effective tool for managing and transferring files securely. Happy file transferring!
