×

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

wc Command in Linux/Unix with Examples

The wc command in Linux is a command-line utility that is used to count the number of lines, words, and characters in a text file or standard input. The name...

4 minutes read.

Difference Between Unix and Linux

Unix vs Linux Unix and Linux both have been of great use in changing the world of operating systems. Unix was among the very few operating systems which were programmed for...

4 minutes read.

Linux cd

Linux cd: As in GUI operating systems like Windows 10, we use the mouse to travel to various folders back and forth; similarly, we have the “cd” command in Linux...

4 minutes read.

ping Command in Linux/Unix with Examples

The "ping" command in Linux (and other Unix-like operating systems) is used to test the connectivity between two networked devices. The "ping" command sends a small packet of data, called...

4 minutes read.

ls Command in Linux/Unix with Examples

The ls command in Linux is a command-line utility that is used to list the files and directories in a directory. It is one of the most basic and commonly...

4 minutes read.

Linux Path Completion

Every operating system has some features which make them special. The Linux operating system primarily works on the command line interface, and we do have many features for this CLI....

1 minute 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.

Linux Distributions

Linux Distributions Linux OS is not like other operating systems. Linux can be modified according to the user’s requirements, and it is very flexible to any change. Linux distributions are often...

4 minutes read.

rename Command in Linux/Unix with Examples

The rename command in Linux is used to rename multiple files at once, using a specified pattern. The command is also known as rename, ren, and mv. This command is...

3 minutes read.

apt-get Command in Linux with Examples

The apt-get command is a command-line tool that is used to handle packages in Linux. This command handles the processes like retrieving the packages and information from authentic sources for...

5 minutes read.

Linux Commands List

Linux Commands List The Linux systems are filled with commands for several use cases. We have divided these commands into some of the most common implementations for a better understanding of...

2 minutes read.

tail Command in Linux/Unix with Examples

The "tail" command in Linux (and other Unix-like operating systems) is used to display the last few lines of a file. By default, the tail command will display the last...

4 minutes 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.

How to change the ApacheHTTP port in Linux

What is an Apache HTTP server in Linux? When we talk about the most commonly used web servers, one of the web servers that cannot be missed is Apache. With the...

4 minutes read.

touch Command in Linux/Unix with Examples

The "touch" command in Linux (and other Unix-like operating systems) is used to create new empty files or update the timestamps of existing files. The touch command is a simple...

4 minutes read.

Difference Between Linux and Windows

Linux vs. Windows Here in this tutorial, we are going to discuss several features of Linux and Windows. These features or characteristics help us to come to a conclusion about which...

5 minutes read.

awk Command in Linux/Unix with Examples

The 'awk' 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...

4 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.

Linux Absolute and Relative Path

The concept of the absolute and relative path is very simple. The names “relative path” and “absolute path” give us little understanding of the concept we are learning here. The...

1 minute read.

mv Command in Linux/Unix with Examples

The 'mv' command in Linux is used to move or rename files and directories. The command stands for "move" and it allows you to move files and directories from one...

3 minutes read.