Under normal circumstances, you would send files to a from your dedicated server using a graphical ftp or sftp program. In some situations, however, you need to use the command line. One particular situation that calls for command-line file transfer is when you are sending data to a another server, such as a remote backup.
In such a case, SCP is the perfect tool to connect to a remote server using SSH and then send your files using secure encryption. This way, you can send files to remote servers without exposing your server, as you would using unsecured FTP.
To send files using SCP, first login to your server via SSH as you normally would. In this example, let’s suppose you want to send a file called system-data.sql to a remote backup server with the IP address 192.168.2.4. You should make note of where you want the files to be saved on the destination server before initiating the command. To begin, enter the following string:
scp system-data.sql email@example.com:/home/user/data-backup
Replace “username” with the actual user name on the backup server, and replace “/home/user/data-backup” with the absolute path to the directory where you want to save the files.
After the transfer finishes, you do not have to disconnect from the remote server or perform any closing procedures. SCP will automatically disconnect. All you have to do is log out from your own server. SCP has many configuration options that you can add to your transfer command. For more information, type “man scp” from the command line.