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
+5.4k Golang : Display advertisement images or strings on random order
+5.3k Javascript : How to loop over and parse JSON data?
+6k Golang : Convert Chinese UTF8 characters to Pin Yin
+5.3k Swift : Convert string array to array example
+10.9k Golang : Create Temporary File
+14.3k Golang : How to pass map to html template and access the map's elements
+8k Golang : Get all countries phone codes
+8.9k Golang : What is the default port number for connecting to MySQL/MariaDB database ?
+26.3k Golang : Get executable name behind process ID example
+34.5k Golang : How to stream file to client(browser) or write to http.ResponseWriter?
+17.2k Google Chrome : Your connection to website is encrypted with obsolete cryptography
+17.4k Golang : Multi threading or run two processes or more example