Using SCP to Transfer files securely

One of the techniques I use to setup servers is to use the command scp (secure copy) to transfer files between servers.

This is how to use this command. If you have a host A that has a file that host B needs, you will do the following:

  1. Log into host A (has the file).
  2. Find the file that you wish to transfer. Use the command scp in this context:

    scp -P portnum /file-to-transfer.txt root@hostB:/file/structure/to/where/you/want/file/to/go/file-to-transfer.txt

    (Note, the ‘-P portnum’ is optional. I use it to obsure the port that runs scp.)

  3. It will ask for the remote system’s password for root or whatever other user name that you use.
  4. The transfer will automatically happen.

It’s that simple! I actually use this to transfer files back to user servers when they accidentally delete those files.

Enjoy!

Leave a Comment