How to SCP Linux

Tux

SCP (Secure Copy) is a command-line tool used in Linux to securely copy files and directories between remote and local systems. The syntax for using SCP is:

SCP Command Syntax

ShellScript
scp [options] [source] [destination]

Copy from local machine to remote machine (push)

Here are the basic steps to use Secure Copy:

  1. Open a terminal on your local machine.
  2. Type the following command to copy a file from your local machine to a remote machine
ShellScript
scp /path/to/local/file username@remote:/path/to/destination

Replace /path/to/local/file with the path of the file you want to copy, username with your username on the remote machine, remote with the IP address or hostname of the remote machine, and /path/to/destination with the destination path on the remote machine.

Copy from a remote machine to a local machine (pull)

Type the following command to copy a file from a remote machine to your local machine:

ShellScript
scp username@remote:/path/to/remote/file /path/to/destination

Replace username with your username on the remote machine, remote with the IP address or hostname of the remote machine, /path/to/remote/file with the path of the file you want to copy, and /path/to/destination with the destination path on your local machine.

Copy recursively from the local machine to a remote machine

Type the following command to copy a directory from your local machine to a remote machine:

ShellScript
scp -r /path/to/local/directory username@remote:/path/to/destination

Replace /path/to/local/directory with the path of the directory you want to copy, username with your username on the remote machine, remote with the IP address or hostname of the remote machine, and /path/to/destination with the destination path on the remote machine.

Copy recursively from the remote machine to a local machine

Type the following command to copy a directory from a remote machine to your local machine:

ShellScript
scp -r username@remote:/path/to/remote/directory /path/to/destination 

Replace username with your username on the remote machine, remote with the IP address or hostname of the remote machine, /path/to/remote/directory with the path of the directory you want to copy, and /path/to/destination with the destination path on your local machine.

These are the basic steps to use SCP in Linux. There are many other options and configurations available for SCP, so you may want to consult the man page (man scp) or the SCP documentation for more information.

Want to learn more Linux facts? Check out the rest of our Tech Quicky content!!
Elsewhere On TurboGeek:  Managing Users & Groups in RedHat

Want more of this kind of guide?

Use the blog and category routes to keep moving through the archive, or support TurboGeek if the site saves you time regularly.

Translate ยป