SCP comes in handy to copy files to a remote server from a computer or vice versa. You can also copy server files to another server.
All you need is your server’s IP address and user credentials to start copying. Here are some common SCP commands use cases.
scp file.zip user@hostip:/home/directory
This command will copy file.zip in your terminals present working directory to the home directory of the server.
scp user@hostip:/home/directory/file.zip ~/Downloads
You are copying file.zip from the server’s home directory to your local downloads folder.
Another use case of the SCP command is during site migration to a new server. Zip your site’s root directory and copy it to the new server.
Provide login credentials and file paths of both servers to SCP in your computer’s terminal.
scp user@remotehost1:/home/file.zip user@remotehost2:/home
-p flag to add port of remote host
scp -p 1122 file.zip user@hostip:/home/directory
-C flag to enable the gzip compression in SSH transfer
scp -C localfile.zip user@hostip:/home/directory
-v Verbose SCP operation
-p <port> Mention remote host port
-P Save the file’s modification and access times
-r Copy recursively
-c <cipher> Specify the cipher for data encryption
So if you are still using an FTP client, use the SCP command in the terminal for a secure transfer.