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
+17k Golang : Get number of CPU cores
+6.7k Golang : Reverse by word
+4.7k Adding Skype actions such as call and chat into web page examples
+9.7k PHP : Get coordinates latitude/longitude from string
+9.6k Golang : Read file with ioutil
+12.7k Golang : Send data to /dev/null a.k.a blackhole with ioutil.Discard
+11.5k Golang : Handle API query by curl with Gorilla Queries example
+6.4k Golang : Handling image beyond OpenCV video capture boundary
+7.9k Golang : Get today's weekday name and calculate target day distance example
+15.2k nginx: [emerg] unknown directive "ssl"
+4.7k Golang : How to pass data between controllers with JSON Web Token
+8.5k Linux/Unix : fatal: the Postfix mail system is already running