General

How to Use the SCP Command to Copy and Transfer Files in Linux

General·March 22, 2026·35 min read

The secure copy protocol (SCP) is a command that facilitates efficient and secure file transfers between two remote systems. Using the SSH

(Secure Shell) protocol to authenticate systems and encrypt data.

SCP streamlines data transfer between Linux systems, as administrators don't need to log into both machines individually. They can quickly and securely copy important files, such as configuration backups, log files, and web content without third-party tools.

In this article, you will learn how to use the SCP command on a remote host, such as HolyHosting's virtual private server (VPS). We will break down the command syntax, provide practical use cases and examples, and describe the most common options.

SCP Command Syntax

How to Copy Files Using the SCP Command

Using the SCP Command with HolyHosting VPS

Copy From a Local Server to a Remote Host

Transfer a Remote File to a Local Machine

Securely Move a File Between Remote Hosts

How to Use the SCP Command With Options

Frequently Asked Questions About Using the SCP Command to Transfer Files

How Do I Run SCP on Windows?

Can I Enter the Password in the SCP Command?

How Do I Stop or Pause SCP?

SCP Command Syntax

The basic SCP syntax for transferring a file between two different remote servers is as follows:

```

scp [options] [source username@IP]:/[directory and file name] [destination username@IP]:/[destination directory]

```

Command breakdown:

- `[options]` – modifiers to alter the behavior of the SCP command.

- `[source username@IP]` – username and IP address of the source system.

- `:/` – separator for system address and directory path.

- `[directory and file name]` – location and name of the file.

- `[destination username@IP]` – user account and IP address of the destination system.

- `[destination directory]` – destination directory for the transferred files.

Example of an SCP command to copy files between two remote systems:

```

scp [email protected]:/media/scp.png [email protected]:/escritorio/destino

```

Make sure to enable root access on the remote machine. If you use another account, verify it has write permissions.

If you are copying from or to a local host, omit the IP address and path like /escritorio/nombre_carpeta. The SCP command will look like this:

```

scp scp.png [email protected]:/escritorio/destino

```

How to Copy Files Using the SCP Command

The following sections will explore some practical examples of using SCP to transfer files between different systems.

Warning! Be careful when using SCP commands, as you can overwrite files and directories with the same name.

Using the SCP Command with HolyHosting VPS

You need to access the bash shell of the source machine to execute the SCP command. For a remote server like a VPS, connect to its terminal using an SSH client application.

If you use HolyHosting's VPS, use the browser terminal feature in the server overview menu in the Members Area. It allows you to connect and run commands on a remote server directly through a web browser, making the task more efficient.

Additionally, our browser terminal uses the VNC protocol to access the remote server, allowing you to run SSH commands like SCP even when the target system closes the connection port.

HolyHosting also offers an AI Assistant for VPS, accessible from the server overview menu. This feature allows you to generate ready-to-use

SCP commands based on your needs, improving management efficiency.

For example, you can enter "Generate the SCP command to transfer the config.yaml file from the /web_app/configuration path on my current server to the /live_app/config remote directory on my VPS. The destination server username is root and its IP address is 168.162.1.2".

The AI Assistant will generate the complete command, which you can copy and paste into the browser terminal, as shown below:

[Image: Screenshot of the HolyHosting AI Assistant generating an SCP command based on the user's request]

Copy From a Local Server to a Remote Host

Using the SCP command to copy files from a local system to a remote host, such as a VPS, helps streamline web application deployment processes. It allows you to quickly send updated files from a local development environment to the live server.

For example, we will copy the local file scp.zip to a remote server with the root user. To do so, specify the remote username and IP address:

```

scp /users/HolyHosting/desktop/scp.zip [email protected]:/escritura/articulo

```

The terminal will prompt you to enter the remote user's password if you haven't set up an SSH key pair. It will also display a progress bar, as shown below:

[Image: Screenshot of the terminal showing a password confirmation prompt and an SCP progress bar]

The SCP command uses the default SSH port 22 to securely copy files. However, server administrators may configure a different listening port to prevent unauthorized access. In this case, add the -P option to enable the custom SCP port:

```

scp -P 2322 /users/HolyHosting/desktop/scp.zip [email protected]:/escritura/articulo

```

To rename the transferred file, specify the new value in your destination directory. Here is an example of the SCP command that renames scp.zip to howtoscp.zip:

```

scp /users/HolyHosting/desktop/scp.zip [email protected]:/escritura/articulo/howtoscp.zip

```

Ad

ditionally, the SCP command allows you to recursively copy directories, enabling you to transfer multiple files within a folder simultaneously. To do so, use scp -r and specify the folder you want to transfer:

```

scp -r /users/HolyHosting/desktop [email protected]:/escritura/articulo

```

The example above will copy the contents of the desktop folder to the remote directory /escritura/articulo, including subfolders. Alternatively, copy multiple files using their names as shown below:

```

scp file1.txt file2.txt file3.txt [email protected]:/escritura/articulo

```

Pro Tip

To find the full path of a directory, navigate to the appropriate directory and use the pwd command.

Transfer a Remote File to a Local Machine

To initiate SCP data transfer from remote systems to local systems, swap the source and destination locations in the syntax. It improves application development efficiency, as you can easily download and work on the project file offline.

For example, use the following command to download the file scp.zip from a remote VPS to a local machine:

```

scp [email protected]:/escritura/articulos/SCP.zip Users/HolyHosting/Desktop

```

Running this command will display the SSH login output, which will require the user's password. If you disable authentication using sudo privileges on the remote server and enable public key authentication, the prompt will not appear.

Securely Move a File Between Remote Hosts

In addition to transferring to or from the current server, use SCP to move files between two remote Linux machines. To do so, run the command on your local computer with their addresses as source and destination.

If you have multiple projects hosted on different remote machines, this helps improve efficiency. Instead of logging into multiple systems individually, you can transfer files between them directly from your current computer.

For example, run the following command to transfer the remote file scp.zip from [email protected] to [email protected]:

```

scp [email protected]:/escritura/articulo/scp.zip [email protected]:/publicacion

```

Copying files between two remote servers requires the SSH passwords for both accounts.

By default, the SCP command transmits data directly from the first remote computer to the second. If you want to redirect the operation through your current local system, add the -3 option as shown in the following command:

```

scp -3 [email protected]:/escritura/articulo/scp.zip [email protected]:/publicacion

```

Use this option if you encounter a network error during the transfer. This usually happens when the source system cannot access the destination system to copy data due to a lack of direct connection.

Redirecting the SCP command to the local host makes the destination server receive files from your computer instead of the source system. However, this process will take longer and skip information such as the progress bar.

How to Use the SCP Command With Options

There are several SCP command options, which are parameters to modify the behavior of data transfer. They are useful for users with advanced technical knowledge who want to copy files in a specific way according to their needs and security requirements.

Options can come in the form of a single character (-o) and its descriptive equivalent (--option). Both work similarly, but some command utilities may not provide the short version.

Unlike other Linux commands, you cannot use the --help parameter to display the SCP manual and acceptable options. Instead, you can do so by running it without parameters:

```

scp

```

A commonly used SCP command option is -q, which tells the system to copy the file in quiet mode. It disables the progress bar output, warnings, and diagnostic messages. Here is an example command:

```

scp -q /users/HolyHosting/desktop/scp.zip [email protected]

```

Use the -v parameter to enable verbose output. It displays detailed debugging messages about the copy process to facilitate troubleshooting. Here is how the command looks:

```

scp -v /users/HolyHosting/desktop/scp.zip [email protected]

```

The -4 and -6 options determine the version of the internet protocol used for data transmission: IPv4 or IPv6. When using them, change the remote location addresses accordingly, as in the following example:

```

scp -4 [email protected]:/users/HolyHosting/desktop/scp.zip

```

Use the -p option to preserve the source file data, such as the mode, modification, and access times. Note that it differs from the uppercase -P option for changing the transfer port. Here is the syntax:

```

scp -p /users/HolyHosting/desktop/scp.zip [email protected]

```

Important! Be careful when using SCP command options, as they are case-sensitive.

The -C option compresses the copied files or directories during the transfer process. It works with all files except compressed archives, such as .zip and .rar. Here is how the command looks:

```

scp -C Folder [email protected]

```

Meanwhile, the lowercase -c option allows you to specify the encryption algorithm of the client machine. It is set to AnyStdCipher by default, but you can use other values such as aes256-ctr, aes256-cbc, and 3des-cbc.

To check all available values, refer to the Ciphers section in the SSH_config manual. Here is an example SCP command with 3des-cbc encryption:

```

scp -c 3des-cbc /users/HolyHosting/desktop/scp.zip [email protected]

If you want to copy a file in a specific way but the SCP command does not have a suitable option, use the -o option. It allows you to apply SSH options from the configuration file to your SCP command.

To use the option, add the configuration key-value pair in quotes, as shown in the following syntax example:

```

scp -o "option=value" /directory/path/file

```

Each -o option only takes one pair as its value. If you want to pass multiple SSH settings, add more options. For example, the following SCP command will connect to the destination system a maximum of two times and end the attempt after five seconds:

```

scp -o "ConnectionAttempts=2" -o="ConnectTimeout=5" /users/scp.zip [email protected]

```

This will not change the configuration file when you pass the SSH settings, as it will only apply to your current SCP session. For more information about the full keys and their values, refer to the SSH_config manual.

Discover Other Linux Commands for Server Management

- [How to Check Disk Space in Linux](#)

- [How to Transfer Data with the Curl Command](#)

- [How to Calculate Process Execution with the Time Command](#)

- [How to Monitor Changes with the Watch Command](#)

- [How to Shut Down and Restart the Server](#)

- [How to Transfer and Sync Data with Rsync](#)

- [How to Kill a Process in Linux](#)

- [The Tee Command for Efficient File Writing](#)

Conclusion

The Linux SCP command allows secure file copying between systems through encrypted SSH, offering a more efficient and secure alternative to FTP. Its syntax involves options, system addresses, file location, and destination path, with the omission of address and directory for local transfers.

SCP not only allows file transfer between local and remote systems but also between two remote systems through a local machine. Options like -P and -

C customize the transfer process.

HolyHosting users can benefit from an AI Assistant to easily generate SCP commands and a browser terminal to execute commands on remote servers through web browsers.

Still have questions?

Come chat with us and we will get back to you as soon as possible!

Contact Support