Close

2019-10-27

What is SCP and Example syntax for Secure Copy (scp)

Linux

What is SCP and Example syntax for Secure Copy (scp)

SCP copies files between different hosts. It uses SSH and provides authentication for remote host

Examples

Copy the file “foobar.txt” from a remote host to the local host

• $ scp remoteusername@remotehost:foobar.txt /some/local/directory

Copy the file “foobar.txt” from the local host to a remote host

• $ scp foobar.txt remoteusername@remotehost:/some/remote/directory

Copy the directory “foo” from the local host to a remote host’s directory “bar”

• $ scp -r foo remoteusername@remotehost:/some/remote/directory/bar

Copy the file “foobar.txt” from remote host “remotehost1” to remote host “remotehost2”

• $ scp remoteusername1@remotehost1:/some/remote/directory/foobar.txt \ remoteusername2@remotehost2:/some/remote/directory/

Copying the files “foo.txt” and “bar.txt” from the local host to your home directory on the remote host

• $ scp foo.txt bar.txt remoteusername@remotehost:~

Copy the file “foobar.txt” from the local host to a remote host using port 2264

• $ scp -P 2264 foobar.txt remoteusername@remotehost:/some/remote/directory

Copy multiple files from the remote host to your current directory on the local host

• $ scp remoteusername@remotehost:/some/remote/directory/\{a,b,c\} .

• $ scp remoteusername@remotehost:~/\{foo.txt,bar.txt\} .