Transferring files between server and local machine.

While maintaining an application in a server, we required to know how to transfer the files between a server and a local machine, and with help of SCP utility, we can easily do that.

SCP copies files between hosts on a network. It uses ssh for data transfer, and uses the same authentication, and provides the same security as ssh. SCP will ask for passwords or passphrases if they are needed for authentication.

Reference — https://linux.die.net/man/1/scp

scp (opt) (from_file_or_directory_loc) (to_file_or_dest_directory_loc)

Remote Server

The remote server should contain some of the mandatory information, like username, host details, file, and folder location. The password is optional and based on the authentication settings, a password will be asked.

user_name@(host_name or ip):(location_of_the_server)

You can find possible use scenarios below:

File from local to a remote machine

scp /users/xxx/test/file.txt root@172.1.23.171:/etc/test/file.txt

File from remote to local machine

scp root@172.1.23.171:/etc/test/file.txt /users/xxx/test/file.txt

Folder from local to a remote machine

scp -r /users/xxx/test/ root@172.1.23.171:/etc/test/

Folder from remote to local machine

scp -r root@172.1.23.171:/etc/test/ /users/xxx/test/

If you have feedback and suggestion feel free to give your comments.

Reach out to me at Twitter, LinkedIn.