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
+6.5k Golang : Break string into a slice of characters example
+16.1k Golang : Get sub string example
+12.4k Golang : List running EC2 instances and descriptions
+6.8k Golang : Reverse by word
+5.8k Golang : Detect words using using consecutive letters in a given string
+22.8k Golang : Strings to lowercase and uppercase example
+8.1k Golang : Sort words with first uppercase letter
+10.6k Golang : Simple Jawi(Yawi) to Rumi(Latin/Romanize) converter
+7.2k Golang : Validate credit card example
+12.5k Golang : Validate email address
+14.1k Golang : Google Drive API upload and rename example
+6.4k Golang : Selection sort example