Tips&Tricks

How to transfer a file from local path to SSH server

SSH (Secure Shell) is a protocol to providing an encrypted channel for logging into another computer over a network and work there.

SCP is like a cp over ssh – coping files from/to remote server over encrypted connection.

So we can use scp to copy file to ssh server:

scp /path/to/local/file user@remote_server:/path/to/destination

For example:

scp ~/project/file.txt root@techdot.tech:/var/www/

Also we can get a file from remote server by switching source and destination:

scp user@remote_server:/path/to/destination /path/to/local/file 

For example:

scp root@techdot.tech:/var/www/ ~/project/file.txt

Be sure that you have enough permissions on your local host and your remote host.