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.8k Javascript : How to check a browser's Do Not Track status?
+22k Find and replace a character in a string in Go
+26.6k Golang : Change a file last modified date and time
+5.8k Fix sudo yum hang problem with no output or error messages
+4.4k Golang : Generate Interleaved 2 inch by 5 inch barcode
+12.7k Golang : Get current time
+27.8k Golang : How to create new XML file ?
+6.8k Javascript : Put image into Chrome browser's console
+22.1k Golang : minus time with Time.Add() or Time.AddDate() functions to calculate past date
+4.9k CodeIgniter/PHP : Remove empty lines above RSS or ATOM xml tag
+10.7k Golang : Perform sanity checks on filename example
+12.7k Android Studio : Use image as AlertDialog title with custom layout example