Categories
Linux shell

secure copy ( SCP ) howto 102

Secure Copy (SCP) provides a secure and authenticated method for copying files between hosts. SCP relies on Secure Shell (SSH).

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

scp [email protected]:somefile.txt /some/local/directory

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

scp somefile.txt [email protected]:/some/remote/directory

Copy the directory “somedir” from the local host to a remote host’s directory “anotherdir”

scp -r somedir [email protected]:/some/remote/directory/anotherdir

Copy the file “somefile.txt” from remote host “example1.com” to remote host “example2.com”

scp [email protected]:/some/remote/directory/foobar.txt \

[email protected]:/some/remote/directory/

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

scp somefile.txt anotherfile.txt [email protected]:~

Copy the file “somefile.txt” from the local host to a remote host using port 1234

scp -P 1234 somefile.txt [email protected]:/some/remote/directory

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

scp [email protected]:/some/remote/directory/\{1,2,3\} .

scp [email protected]:~/\{somefile1.txt,somefile2.txt\} .