Useful when you need to copy files to server or get them from server.
The basic syntax is:
Copy to server
scp /file/to/send [email protected]:/where/to/put
scp ~/image.jpg [email protected]:/root/images
If you use config file for SSH you can use host names
[email protected] -> serverName
scp ~/image.jpg serverName:/root/images
You can pass a custom port (22 by default) for a server connection by
scp -P 22022 ~/.db [email protected]:/.db
Copy files between servers
Remember: when you copy files between servers, your server
remote2 (target) should have ssh public key of server
-r key to copy elements recursively
scp -r ~/images [email protected]:/root/
images will be created automatically.