Home Wiki > SDB:SCP usage
Sign up | Login

SDB:SCP usage

tagline: From openSUSE

SCP is a secure way to copy files from, to and between remote hosts. This program comes with the openSSH package. This page describes the usage of SCP.
Tested on openSUSE Recommended articles Related articles
Icon-checked.png

Icon-manual.png Icon-help.png

General

You must have the OpenSSH package installed, which is by default in openSUSE. Also you will need a configured SSHD to accept connections on the remote host, before using SCP.

SCP is based on RCP. It allows the user to copy files over a secure channel between computers. SCP is non interactive, meaning you will have to know where the file is you want to copy and you will have to make sure the destination path exists. It is a nice way to quickly transfer a single file or a directory (in recursive mode) to an other computer. If you are interested in a more interactive way of accessing, downloading and uploading your files, you probably want to use SFTP.


Usage

$ scp (options) user@host:/original/file user@host:/copied/file

As with all openSSH commands, when the user is not specified, the current user name is used. Authentication methods are similar to the ssh command. Host can be replaced for any adress, similair to the ssh command. When a host is not specified, it means the local computer. Using 2 hosts is allowed, so you can copy a file from "remote host A" to "remote host B", without having the transfer through your own local computer. "Remote host A" must be allowed to connect "remote host B" and you will have to authenticate for both remote hosts. (Eg. password or public key)

Examples

If you want to copy a file from the server to the client enter:

$ scp user@ssh.host.org:/path/to/file /where/to/save

If you want to copy a file from the client to the server enter:

$ scp /path/to/file user@ssh.host.org:/where/to/save

If you want to copy a file between the remote hosts

$ scp user@ssh.host.org:/path/to/file user@ssh.host2.org:/where/to/save

Usefull options

Some usefull options. These are just some common used options

-C Compression enabled. This option is passed to ssh to enable compression. Usefull over slow connections. Not recommended on fast connections.
-l Limits the bandwith with a specified number in Kbit/s
-o Specify one or more ssh_config options. With this option you can specify any option as used in the ssh_config file. Refer to man ssh_config for available options.
-p Preserves timestamps and modes.
-r Recursive mode for copying complete directories.