While this is great for transferring files and directories in bulk, what if just a single file or a few files need to be copied quickly? For this, scp (secure copy) can be very useful. It is a remote file copy tool available from Linux Terminal that uses ssh to copy files between different Linux systems.
Suppose a file named readme.txt needs to be copied from local Linux system to a remote server which only accepts ssh connections over a non-standard port like say 2222 instead of the default port 22.
To accomplish this copying, the command that needs to be executed from the local Linux system will be :
This will first open a ssh connection to the remote system and once authenticated, will copy the local file to that system. The copied file will now be available on remote system in the default directory :
To copy directly using standard ssh port 22, simply omit the P flag :
This also can be useful when trying to upload files to the remote server without using FTP and also provides great security.