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.9k Golang : How to feed or take banana with Gorilla Web Toolkit Session package
+6.4k Golang : Hue, Saturation and Value(HSV) with OpenCV example
+4.4k Javascript : How to loop over and parse JSON data?
+15.4k Golang : Gzip file example
+6.3k Golang : alternative to os.Exit() function
+25k Golang : Convert file content into array of bytes
+8.9k Golang : Setting variable value with ldflags
+11.4k Golang : HTTP response JSON encoded data
+9k Golang : Random Rune generator
+16k Golang : How to make a file read only and set it to writable again?
+15.6k Golang : Get input from keyboard
+4.2k Python : Create Whois client or function example