×

Linux SCP Command

SCP stands for secure copy protocol. It is a command-line application for copying files and directories safely between two places. Command-line utilities are programs that operate on a computer's command line. A file or directory can be copied from your local computer to a remote system or vice versa using SCP. SCP is well-known for its simplicity and security. While transferring files with SCP, both the user's files and password are encrypted. To transfer files, the SCP needs an SSH service. To do so, an ssh key or ssh password is also required.

What is SSH?

It is a network protocol whose main aim is to access a computer while using or accessing a network that can be termed unsafe or unsecured. Secure Shell and Secure Socket Shell are other names for it. TatuYlonen created the initial version, which was released in 1995. Many versions of SSH got created with time, such as SSH-1, SSH-2, etc. It provides the following features, such as:

  • password authentication
  • public key
  • File transfer sessions that are interactive.
  • File transfer sessions that are fully automated.
  • Systemized management
  • Encrypted data communications between destination computer and source computer.

SSH uses a client-server model. A client-server architect makes advantage of server-side services. Secure Shell connects to servers, makes modifications, uploads files, and exits using tools or the terminal directly. SSH keys are commonly used in scripts, backup systems, and configuration management applications to automate access to servers.

SSH is an open-source protocol which means its versions are available at zero cost. It has been integrated into the majority of computing platforms. The OpenSSH implementation is the most extensively used on Linux, UNIX, and other operating systems. It has a feature called SSO, which stands for single sign-on.

SCP Command Syntax

Before getting into SCP Command, one should be well-versed with the basic syntax of SCP. The following is an example of how SCP Command Syntax looks while coding.

Linux SCP Command

Option Tag

Scp gives its users the following options:

  • Scp –P port:  This port is used while connecting to the remote host.
  • Scp –p:  It saves access, modification, and modes from the source file.
  • Scp –q: It turns off the progress meter.
  • Scp –r: It is used to entire directories.
  • Scp –C: When data is transferred to the target machine, this option compresses it.
  • SCP- V: It causes connection, authentication, and configuration issues to be debugged.
  • SOURCE_HOST:] file 1: It is a source file.
  • DESTINATION_HOST:] file 1: It is a destination file.

How to Use SCP?

The SCP client may upload or retrieve files and directories from the SSH server. In exchange, the server transmits all of the subdirectories and files that are accessible for download. The server is in charge of file downloads; therefore, there may be security problems if the client is mistakenly linked to a hostile server. The easiest way to do so is by typing 'SCP' in the command prompt, and it will show all SCP options and ports. SCP may be found in most operating systems, including Windows, Linux, and macOS.

Linux SCP Command

Both commands must have a source and destination file-system location to perform a copy operation. The key distinction is that the SCP requires using a remote system at one or both sites.

How to Copy Files from Local to Remote with SCP?

Linux SCP Command
  • F1.zip is the name of the file we want to copy.
  • Sahil @myhost is the name of the user or user itself, which is present on the remote server.
  • /main/sahil/archive is the destination path where the file will get copied.
  • 10.10.2.0 is the IP address.

Entering the above code in your terminal window will upload the local file name f1.zip into the server myhost.com into the remote directory /main / sahil.

If no remote directory is specified, the file will be copied to the remote user's home directory. When prompted, input or paste the password after pressing enter. After then, the file will be uploaded to a remote server. 

How to Copy Files from Remote to Local with SCP?

Linux SCP Command

A remote location will be used as the source and the local location as the destination. After entering the above code, f1.zip will be copied to the above IP.


Related Topics

cat Command in Linux/Unix with Examples

The cat command in Linux is a command-line utility that is used to display the contents of a text file. It stands for "concatenate" and it is used to view...

4 minutes read.

Linux rmdir command

The default use case of the rmdir command in the Linux system is to delete an empty directory. The below screenshot shows how to delete the empty directory. First, we...

1 minute read.

telnet Command in Linux/Unix with Examples

The telnet command in Linux is a command-line utility that allows you to connect to a remote host using the Telnet protocol. Telnet is a network protocol that provides a...

3 minutes read.

cp Command in Linux/Unix with Examples

The cp (copy) command in Linux is a command-line utility that is used to copy files and directories. It is one of the most basic and commonly used commands in...

5 minutes read.

df Command in Linux/Unix with Examples

The 'df' command in Linux is used to display the amount of disk space available on the file system. The command reports the amount of disk space used and available...

3 minutes read.

sed Command in Linux/Unix with Examples

The 'sed' command in Linux is a powerful text processing tool that allows you to perform various operations on text files, such as searching, replacing, and manipulating text. The command...

3 minutes read.

adduser Command in Linux with Examples

What is the adduser command? The adduser command creates a new user, and this command may be used to add apre-existing user to a group that already exists. How to use the...

4 minutes read.

Linux SCP Command

SCP stands for secure copy protocol. It is a command-line application for copying files and directories safely between two places. Command-line utilities are programs that operate on a computer's command...

3 minutes read.

echo Command in Linux/Unix with Examples

The "echo" command in Linux is used to display a line of text on the terminal. It can also be used to print the value of a variable or to...

3 minutes read.

rm Command in Linux/Unix with Examples

The "rm" command in Linux (and other Unix-like operating systems) is used to remove files and directories. The "rm" command stands for "remove" and it is used to delete files...

4 minutes read.

unzip Command in Linux/Unix with Examples

The 'unzip' command in Linux is used to extract files from a ZIP archive file. The command allows you to decompress and extract the files and directories stored in a...

3 minutes read.

top Command in Linux/Unix with Examples

The 'top' command in Linux is a real-time system monitoring tool that displays information about the running processes and system resource usage. The command provides a dynamic, scrolling view of...

4 minutes read.

ps Command in Linux/Unix with Examples

The 'ps' command in Linux is used to display information about the running processes on a system. The command stands for "process status" and it allows you to view details...

4 minutes read.

pwd Command in Linux/Unix with Examples

The "pwd" command in Linux (and other Unix-like operating systems) stands for "print working directory." When executed, it simply displays the current directory (or folder) that the user is currently...

3 minutes read.

mkdir Command in Linux/Unix with Examples

The "mkdir" command in Linux (and other Unix-like operating systems) is used to create new directories. The "mkdir" command stands for "make directory" and it is used to create a...

3 minutes read.

du Command in Linux/Unix with Examples

The "du" command in Linux (and other Unix-like operating systems) is used to estimate the space used by a file or directory. The du command stands for "disk usage," and...

4 minutes read.

gzip Command in Linux/Unix with Examples

The gzip command in Linux is used for compressing and decompressing files. It uses the Lempel-Ziv coding (LZ77) algorithm to compress files, which is known for its high compression ratio...

6 minutes read.

Linux mkdir | Linux Create Directory

The Linux mkdir command is very much similar to Windows’s "new folder" feature. This command is used in Linux os to create new directories. The command mkdir stands for "make...

1 minute read.

curl Command in Linux/Unix with Examples

The 'curl' command in Linux is a command-line tool that allows you to transfer data from or to a server using various protocols, including HTTP, HTTPS, FTP, and many more....

3 minutes read.

find Command in Linux/Unix with Examples

The find command in Linux is a command-line utility that is used to search for files and directories in a file system. It is a versatile command that can be...

5 minutes read.