SCP stands for secure copy. It allows you to copy files securely over SSH. It is very useful if you wish to send local files from your computer to an remote location. I find one of the most useful features of SCP is that it makes an session for the copy and it automatically disconnects after the file has successfully transferred. If i was to SSH into the server normally to make the file transfer and the file happens to be an large file, I may end up leaving SSH logged in on my computer, this would pose as an security risk.
As SCP works on an session basis, I can enter my password for the files to be copied and once it has been copied, the session to the server is disconnected automatically.
To copy from local computer to server: scp image.jpeg firstname.lastname@example.org:/var/www/html
With the above command, it will use “secure copy” with the file “image.jpeg” to the server called “mysuperweb.co.uk”. To access the server we will be using the username “root”. The file “image.jpeg” will be placed in the location of “/var/www/html”. This means our file can be found at: “/var/www/html/image.jpeg”.
At this stage, to authenticate the username of “root” at the server “mysuperweb.co.uk”, you will be asked to enter the password. If the password is correct, the secure copy will start; else you will need to enter the password again. Once the secure copy has finished coping the file “image.jpeg” the secure copy will disconnect from the server of “mysuperweb.co.uk”.
To SCP folders as well you would need the -r flag.
To preserve the time stamp you would need the -p flag.
To copy all folders and files from remote server to the local computers path. scp -rp email@example.com:/var/www/html/* .