Unix/Linux : secure copying between servers with SCP command examples
Have to write this down in case I forget again and hope you may find these SCP examples useful too.
Example 1:
To copy a single file :
scp sourceFile user@targetServer:targetDirectory/targetFile
Example 2:
To copy entire directory(plus sub directories) over to remote server :
scp -r sourceFolder user@targetServer:targetDirectory/targetFolder
Example 3:
To copy single file from remote server to local server:
scp user@remoteServer:remoteDirectory/remoteFile localFile
Example 4:
To copy entire directory from remote server to local server:
scp -r user@remoteServer:remoteDirectory/remoteFolder localFolder
NOTE : By default SCP works on port 22, in case the remote server has different port for SCP. You can specify the port number by the -p option :
scp -p 3300 -r user@remoteServer:remoteDirectory/remoteFolder localFolder
References :
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+27.1k Golang : How to get HTTP request header information?
+19k Golang : Convert(cast) string to uint8 type and back to string
+3.8k Fix ERROR 2003 (HY000): Can't connect to MySQL server on 'IP address' (111)
+8.8k Golang : Increment string example
+8.8k Golang : Encrypt and decrypt data with x509 crypto
+9.3k Golang : package is not in GOROOT during compilation
+4.5k Golang : Reverse by word
+4.1k Golang : Check if password length meet the requirement
+6.9k Golang : Format numbers to nearest thousands such as kilos millions billions and trillions
+3.2k Swift : Convert (cast) Float to Int or Int32 value
+16.3k Golang : Pipe output from one os.Exec(shell command) to another command
+3.7k Golang : How to setup a disk space used monitoring service with Telegram bot