Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...


For example, if you want to copy a file named users.csv to a directory called Documents on a remote computer with IP 10.72.5.100 with username aqua enter:
scp users.csv aqua@10.72.5.100:~/Documents

Copy a local file to a remote directory with a different filename:

...


For example, if you want to copy a file named users.csv and rename it to data.csv enter:
scp users.csv aqua@10.72.5.100:~/Documents/data.csv

  Copy local files to a remote directory:

...


For example, if you want to copy all sql file with extension .sql to a remove directory enter:
scp *.sql aqua@10.72.5.100:~/Documents

Copy a local directory to a remote directory, note that the /tmp/dirName directory on the remote machine needs to be created beforehand:

...


For example, to copy a local directory named csv to a remote machine enter:
scp /home/tariq/csv aqua@10.72.5.100:~/Documents

Copy a remote file to a local directory:

...


For example, to copy a file from a remote host named data.log to the local machine under a folder named temp enter:
scp aqua@10.72.5.100:~/Documents/data.log temp/

Copy a remote directory to a local directory, note that the trailing asterisk after the from the directory is required in order for directory copy to work:
Code Block
scp username@hostname:/tmp/fromDirectory/* /tmp/toDirectory

For example: scp aqua@10.72.5.100:~/Documents/* temp/

Copy a local file in the working directory to a remote directory with a custom identity file use the -i option.

...


For example, if you want to copy a file named users.csv to a directory called Documents on a remote computer with an identity file enter the below command.
id_rsa is the so called private key when you generate an SSH key public/private key pair.
scp -i /home/tariq/.ssh/id_rsa users.csv aqua@10.72.5.100:~/Documents

NOTES
If the destination to where file(s) to be copied is a directory, then the destination directory needs to be created before the scp command is executed;
otherwise, exception will be thrown.