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
+26.3k Mac/Linux and Golang : Fix bind: address already in use error
+10.4k Golang : Check a web page existence with HEAD request example
+6.9k Golang : Output or print out JSON stream/encoded data
+30.5k Golang : How to redirect to new page with net/http?
+10.8k Golang : ISO8601 Duration Parser example
+18.9k Golang : Iterating Elements Over A List
+7.1k Android Studio : Hello World example
+18.5k Golang : Put UTF8 text on OpenCV video capture image frame
+11.7k Use systeminfo to find out installed Windows Hotfix(s) or updates
+19.5k Golang : Calculate entire request body length during run time
+7.3k Golang : Array mapping with Interface
+9.6k Golang : Qt Yes No and Quit message box example