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
+11.3k Golang : How to detect a server/machine network interface capabilities?
+5.7k Golang : Build new URL for named or registered route with Gorilla webtoolkit example
+8k PHP : How to parse ElasticSearch JSON ?
+6.7k CloudFlare : Another way to get visitor's real IP address
+15.2k Golang : Get current time from the Internet time server(ntp) example
+5.2k Golang : Detect words using using consecutive letters in a given string
+14.4k Golang : How to check for empty array string or string?
+5.3k Golang : ROT32768 (rotate by 0x80) UTF-8 strings example
+50.8k Golang : Check if item is in slice/array
+8.6k Golang : What is the default port number for connecting to MySQL/MariaDB database ?
+7.3k Golang : Trim everything onward after a word
+14.8k Golang : How to add color to string?