1. Home
  2. Linux

Ubuntu: copy files over SCP [Guide]

If you need to copy files over the SCP protocol, the best way to do it is via the Ubuntu command-line. SCP isn’t as complicated as it is made out to be, and with some guidance, you’ll be able to figure out how to transfer any file or folder you like!

Ubuntu: copy files over SCP

Copy files over SCP via the command-line

To start copying files over SCP, you’ll need to ensure that the computer you plan to transfer files to has an SSH server set up. Setting up an SSH server on Ubuntu is incredibly easy, as the operating system does all the heavy lifting.

Follow the step-by-step instructions below to set up an SSH server on the computer you plan to transfer files to via SCP.

Step 1: Open up a terminal window on the remote Ubuntu PC. You can open up a terminal window by pressing Ctrl + Alt + T on the keyboard or by searching for “Terminal” in the app menu.

Step 2: Once the terminal window is open, make use of the apt install command to get the “openssh-server” package installed. This package contains everything you need to run an SSH server on Ubuntu.

sudo apt-get install openssh-server

Step 3: Following the installation of OpenSSH on the remote Ubuntu PC, it is time to test the SSH connection. To do that, connect over SSH via the “localhost” address.

Connecting to the “localhost” address in SSH allows you to SSH to your own PC for testing purposes.

ssh ubuntu-username@localhost

After successfully logging in, follow along below to learn how to copy files over SCP.

Copy files over SCP in terminal

The remote Ubuntu box has an SSH server configured, and it has been tested and is working. It is now time to copy over files via the SCP protocol. To do it, open up a terminal window on the Ubuntu PC that is copying files to the remote Ubuntu PC.

Note: if you are not using Ubuntu to copy files over SCP, do not worry. A wide variety of Linux OSes supports SCP, and the instructions below will work.

SCP is a bit complex, so we will break down the command step-by-step. Follow along below.

Step 1: In the terminal, write the first part of the command, followed by the location of the file you wish to copy over. It should look like the example below.

scp /home/username/my/file/to/copy.file

Step 2: Add in the remote Ubuntu PC’s user account as well as the hostname. In this example, the remote Ubuntu PC’s username is “derrik,” and the hostname is “ubuntu-desktop.”

scp /home/username/my/file/to/copy.file derrik@ubuntu-desktop:

Step 3: Add in where the file you are transferring over SCP should land on the remote Ubuntu PC. In this example, the file will save to /home/derrik/Desktop/.

scp /home/username/my/file/to/copy.file derrik@ubuntu-desktop:/home/derrik/Desktop/

Step 4: Once the entire command is filled out, it should look similar to the example below. Press the Enter key to start the transfer process. Keep in mind that both PCs must be on the same LAN for it to work correctly.

scp /home/username/my/file/to/copy.file derrik@ubuntu-desktop:/home/derrik/Desktop/

Copy files over SCP with WinSCP in Wine

While SCP in the command-line works fine, it’s not for everyone. An alternative to SCP in the terminal is WinSCP, a popular Windows application that allows users to transfer files over SCP with a GUI.

Unfortunately, WinSCP has not been ported to Linux. However, it can run on Linux quite smoothly with the latest version of Wine. To get started, open up a terminal window on Ubuntu and install Wine’s newest release with the command below.

sudo apt install wine

Next, download WinSCP to your PC and use the commands to start the installation of WinSCP. 

cd ~/Downloads

wine WinSCP-*.exe

Follow the on-screen prompts to get WinSCP installed. Once it is installed, follow the step-by-step instructions below to copy files over SCP with it.

Step 1: In the login window that appears at startup, find “File protocol” and set it to “SCP.”

Step 2: Find the “Host name” box and write in the Ubuntu PC’s hostname you are trying to transfer to. In this example, we’ll use “ubuntu-desktop.”

Step 3: Enter the remote Ubuntu PC’s username and password in the user and password boxes. 

Step 4: Find the “Save” box and click it. Then, select “Login” to log in to the remote PC via SCP.

Step 5: Open up the Ubuntu file manager and locate the file you wish to transfer. Then, using WinSCP, access the remote folder you want to transfer the file to using the built-in browser.

Step 6: Using the Ubuntu file manager, drag the file into the WinSCP folder. 

Step 7: After dragging a file into the remote WinSCP folder, a pop-up will appear. Click “OK” to transfer the file.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.