LinuxCommandLibrary

scp

secure copy (remote file copy program)

TLDR

Copy a local file to a remote host

$ scp [path/to/local_file] [remote_host]:[path/to/remote_file]
copy


Use a specific port when connecting to the remote host
$ scp -P [port] [path/to/local_file] [remote_host]:[path/to/remote_file]
copy


Copy a file from a remote host to a local directory
$ scp [remote_host]:[path/to/remote_file] [path/to/local_directory]
copy


Recursively copy the contents of a directory from a remote host to a local directory
$ scp -r [remote_host]:[path/to/remote_directory] [path/to/local_directory]
copy


Copy a file between two remote hosts transferring through the local host
$ scp -3 [host1]:[path/to/remote_file] [host2]:[path/to/remote_directory]
copy


Use a specific username when connecting to the remote host
$ scp [path/to/local_file] [remote_username]@[remote_host]:[path/to/remote_directory]
copy


Use a specific ssh private key for authentication with the remote host
$ scp -i [~/.ssh/private_key] [local_file] [remote_host]:[/path/remote_file]
copy

SYNOPSIS

scp [-346BCpqrTv] [-c cipher] [-F ssh_config] [-i identity_file] [-J destination] [-l limit] [-o ssh_option] [-P port] [-S program] source ... target

DESCRIPTION

scp copies files between hosts on a network. It uses ssh(1) for data transfer, and uses the same authentication and provides the same security as ssh(1). scp will ask for passwords or passphrases if they are needed for authentication.

The source and target may be specified as a local pathname, a remote host with optional path in the form off [ on or a URI in the form off scp:// [ on Local file names can be made explicit using absolute or relative pathnames to avoid scp treating file names containing `: ' as host specifiers.

When copying between two remote hosts, if the URI format is used, a port may only be specified on the target if the -3 option is used.

The options are as follows:

EXIT STATUS

-std scp

HISTORY

scp is based on the rcp program in BSD source code from the Regents of the University of California.

AUTHORS

Timo Rinne <tri@iki.fi> Tatu Ylonen <ylo@cs.hut.fi>

SEE ALSO

sftp(1), ssh(1), ssh-add(1), ssh-agent(1), ssh-keygen(1), ssh_config(5), sshd(8)

Copied to clipboard