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

- Oct 30
- 4 min read
The Secure Copy Protocol (SCP) is a command that enables efficient and secure file transfers between two systems over a network. It uses the Secure Shell (SSH) protocol to authenticate systems and encrypt data.
SCP streamlines data transfers between Linux systems, as administrators don’t need to log into both servers. It’s also more secure than other methods, such as the File Transfer Protocol (FTP), which is commonly used to manage remote systems.
In this article, you’ll learn how to use the SCP command on a remote host, such as a Virtual Private Server (VPS).
How do I run SCP on Windows?
Can I enter the password directly in the SCP command?
How do I stop or pause SCP?
SCP Command Syntax
The basic syntax for SCP to transfer a file between two different remote servers is:
scp [options] [source_user@IP]:/[directory and filename] [destination_user@IP]:/[destination directory]
Command breakdown:
[options] – Modifiers that alter the behavior of the SCP command.
[source_user@IP] – Username and IP address of the source system.
:/ – Separator between system address and directory path.
[directory and filename] – Location and name of the file.
[destination_user@IP] – Username and IP address of the destination system.
[destination directory] – Target directory for transferred files.
Example of copying a file between two remote systems:
scp root@162.168.1.1:/media/scp.png holyhosting@162.168.1.2:/desktop/destination
Make sure root access is enabled on the remote machine. If using another account, verify it has write permissions for the target folder; otherwise, files can only be transferred to the user’s home directory.
If copying to or from a local host, omit the IP address and use a local path like /desktop/folder_name. The command will look like:
scp scp.png holyhosting@162.168.1.2:/desktop/destination
How to Copy Files Using the SCP Command
⚠️ Warning: Be cautious when using SCP commands, as they can overwrite existing files and directories with the same name.
Using SCP with HolyHosting VPS
You must access the bash shell on the source machine to run SCP. For remote servers like a VPS, connect via SSH using PuTTY or your computer’s terminal.
If you’re using HolyHosting VPS, use the browser terminal from the server overview menu in your Client Area. It allows you to connect and execute commands remotely through a web browser — making the process more efficient.
Our browser terminal uses the VNC protocol for remote access, letting you execute SSH commands such as SCP even when the target system’s connection port is closed.
HolyHosting also provides an AI VPS Assistant, accessible from the server overview menu. This feature can automatically generate ready-to-use SCP commands based on your input, improving management efficiency.
For example, you could type:
“Generate an SCP command to transfer the file config.yaml from /web_app/configuration on my current server to the remote directory /live_app/config on my VPS. The destination username is root and its IP address is 168.162.1.2.”
The AI Assistant will produce the complete SCP command, which you can copy and paste directly into your browser terminal.
Copying from a Local Server to a Remote Host
Using SCP to copy files from a local system to a remote host, such as a VPS, helps streamline web app deployment. It lets you quickly send updated files from a local development environment to your live server.
For example, to copy the local file scp.zip to a remote server under the root user:
scp /users/HolyHosting/desktop/scp.zip root@162.168.1.2:/write/article
If SSH keys aren’t configured, the terminal will prompt for the remote user’s password and display a progress bar during the transfer.
The SCP command uses port 22 by default for secure file transfers. To use a custom port, include the -P option:
scp -P 2322 /users/HolyHosting/desktop/scp.zip root@162.168.1.2:/write/article
To rename the transferred file:
scp /users/HolyHosting/desktop/scp.zip root@162.168.1.2:/write/article/howtoscp.zip
To copy directories recursively and transfer multiple files at once:
scp -r /users/HolyHosting/desktop root@162.168.1.2:/write/article
To copy multiple files simultaneously:
scp file1.txt file2.txt file3.txt root@162.168.1.2:/write/article
💡 Pro Tip: Use the pwd command to find the full path of your current directory.
Transferring a Remote File to a Local Machine
To transfer files from a remote system to a local one, simply reverse the source and destination order in the command syntax.
Example:
scp root@162.168.1.2:/write/articles/scp.zip /Users/HolyHosting/Desktop
Securely Moving a File Between Remote Hosts
You can also use SCP to transfer files between two remote Linux machines directly from your local computer.
Example:
scp root@162.168.1.2:/write/article/scp.zip holy@162.168.1.1:/publish
To route the transfer through your local host, use the -3 option:
scp -3 root@162.168.1.2:/write/article/scp.zip holy@162.168.1.1:/publish
Using SCP Command Options
SCP supports various options that modify how data is transferred. These are useful for advanced users who need more control and customization.
Common examples include:
scp -q /users/HolyHosting/desktop/scp.zip root@162.168.1.2 # Quiet mode
scp -v /users/HolyHosting/desktop/scp.zip root@162.168.1.2 # Verbose/debug mode
scp -4 root@162.168.1.2:/users/HolyHosting/desktop/scp.zip # Force IPv4
scp -p /users/HolyHosting/desktop/scp.zip root@162.168.1.2 # Preserve timestamps
scp -C folder root@162.168.1.2 # Compress during transfer
scp -c 3des-cbc /users/HolyHosting/desktop/scp.zip root@162.168.1.2 # Use specific encryption
scp -o "ConnectionAttempts=2" -o "ConnectTimeout=5" /users/scp.zip root@162.168.1.2
⚠️ Note: SCP options are case-sensitive — for example, -p is different from -P.
Conclusion
We hope this guide has been helpful! 🚀 Remember, don’t hesitate to ask questions on the HolyHosting Discord or contact our support team.
Follow us on Twitter @HolyHosting to stay up to date.

Stuffy @ HolyHosting


















