Transfer Files to Ubuntu Server with WinSCP

Okay, I came across a situation where I was wondering how to transfer files to my Ubuntu server without a desktop environment. Although I knew this could be done using the FTP protocol, I needed an easy application to transfer files from my Windows laptop to my Linux server. After a bit of internet research, I came across many applications such as FileZilla, Cyberduck, WinSCP, etc. I decided to try WinSCP.

The first step is to check if the SSH connection is enabled on my Ubuntu server. To do this, you need to run the command "sudo systemctl status ssh" on your Linux terminal. From the image below, I can see that the SSH connection is enabled.

If the SSH service is not installed on your Ubuntu server, then you would need to install it by running the command "sudo apt-get install openssh-server". Once installed, you can run the command "sudo systemctl status ssh" to see if the SSH service is active and running.

By default, the SSH connection uses port 22. You need to make sure that the SSH traffic is allowed through your Ubuntu server firewall. You can allow the SSH traffic by running the command "sudo ufw allow ssh".

Okay, great! Before installing WinSCP, you would need your Ubuntu server username, password, and IP address. Since you would already know your username and password to log in to your Ubuntu server, and for the IP address, run the command "ip addr show". Here, mine is "172.30.141.164".

Okay, now download the WinSCP utility from their official webpage https://winscp.net/eng/download.php and install it. Once installed, run the application and click the "New Session" icon.

Once you click the "New Session" icon, a pop-up window will appear asking for the Host name, which is your Ubuntu server IP address, port (which is by default 22), username, and password of your Ubuntu server.

You may want to save the session so that you don't have to enter all the details whenever you would like to use WinSCP later on. Name the session whatever name you like; I chose "Ubuntu UAT Server" for myself.

Once saved, click "login," and a warning window will pop up. There's nothing to worry about, as this message says that WinSCP did not find any saved SSH host keys on the local machine. This message appears whenever you're trying to make an SSH connection to a new server. Click "yes," enter your Ubuntu server password on the next window, and you're good to go.

Great! We are now connected to our Ubuntu server. Now you can easily copy your files from Windows to your server. The left panel in the image below represents the file directory on your Windows machine, and the right side is for your Ubuntu server.

Okay, now let's test if the files can be copied from my Windows to my Ubuntu server. I created a text file with some text on it and dragged it to the right panel. From the image below, you can see that the file was successfully transferred from my Windows machine to my Ubuntu server. There you go, the test is successful. Happy using WinSCP to transfer files.

Oh yes, one thing to mention here is that establishing the SSH connection just using the username and password is not the recommended method in terms of greater security for your Ubuntu server. I always use the public key authentication method instead, with the key files password-protected. I will make another blog on how to establish an SSH connection with this approach.

 

Eiraj Amin

Created on: March 13, 2023