Replace FTP with the SCP command in the terminal

Replace FTP with the SCP command in the terminal

Linux secure copy SCP command

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.

Copy file from your computer to a remote server

scp user@hostip:/home/directory

This command will copy in your terminals present working directory to the home directory of the server.

Copy file from a remote server to your computer

scp user@hostip:/home/directory/ ~/Downloads

You are copying from the server’s home directory to your local downloads folder.

SCP between two remote hosts from your computer

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/ user@remotehost2:/home

SCP Options

Mention transfer port

Add -p flag to add port of remote host

scp -p 1122 user@hostip:/home/directory

Use file compression

Add a -C flag to enable the gzip compression in SSH transfer

scp -C user@hostip:/home/directory

More SCP Options

  • -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.