Copying Files Using Scp Utility On Linux

Posted By : Mohit Shakya | 31-Dec-2017

Hi,
In this blog, we'll learn how to copy a remote server file using scp to another server/local system.

Requirments:
* You should have installed 'OpenSSH-server' on the target machine.
* machine should be on the same network

Steps:
-> To copy a single file ( let say '/home/sysAdmin/xyz.log' to target machine's home location with ip and user are '192.168.0.26' (in case of VPN network it'll be machine's VPN ip) and 'max' respectively)

[ when it's not required to specify credential file. ]

$ scp /home/sysAdmin/xyz.log [email protected]:~/

[ when it's not required to specify credential file. ]

$ scp -i <credential/pem_file> /home/sysAdmin/xyz.log [email protected]:~/

 

 

-> Now to copy an entire directory ( let say directory : /home/sysAdmin/tempDir )

[ when it's not required to specify credential file. ]

$ scp -r /home/sysAdmin/tempDir [email protected]:~/

 

[ when it's not required to specify credential file. ]

$ scp -i <credential/pem_file> -r /home/sysAdmin/tempDir [email protected]:~/

 

In the above steps, may be you'll be asked for target machine's password, please provide that.

That's all. I hope, this will be useful in  some way.

Thanks.

About Author

Author Image
Mohit Shakya

Mohit has worked in groovy and grails, filesystems, ffmpeg. Mohit likes to be adventurous, likes music, solving puzzles, playing chess, and basketball.

Request for Proposal

Name is required

Comment is required

Sending message..