Skip to content

Secure Copy Protocol (SCP)🔗

Secure Copy Protocol (SCP) is a means of securely transferring computer files between a local host and a remote host or between two remote hosts. It's based on the Secure Shell (SSH) protocol.

Basic Usage🔗

To copy a file from a remote server to your local machine:

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

To copy a file from your local machine to a remote server:

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

To copy a directory from your local machine to a remote server:

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

This document provides a brief overview of SCP, its commonly used arguments, and basic usage examples.

Advanced Usage🔗

Commonly Used Arguments🔗

  • -P port: Specifies the port to connect to on the remote host.
  • -p: Preserves modification times, access times, and modes from the original file.
  • -r: Recursively copy entire directories.
  • -v: Verbose mode. SCP will print debugging messages about its progress. This is helpful for debugging connection, authentication, and configuration problems.
  • -C: Compression enable. Passes the -C flag to ssh to enable compression.
  • -i identity_file: Selects the file from which the identity (private key) for public key authentication is read.

To scp from the h4hdata node to your local machine:

Try it yourself🔗

Copy a file from the h4hdata node to your local machine's home directory

Solution
scp -P $H4HDATA_PORT "<username>@$H4HDATA:/path/to/remote/file" $HOME/