scp Command: Remote File Copy

by lifeLinux on November 25, 2010

Some times you need to copy files or entire contents of directory to another machine, you can use scp command. scp command uses SSH data transfers, so it requires a password or passphrase for authentication.

The syntax for scp command

scp [option] [[email protected]]:[source] [[email protected]]:[destination]

For example

If user user1 on a computer called server1 and wants to copy a file called mydata.txt to a directory called backup in his account on a computer called server2, he would enter:

[[email protected]]$ scp mydata.txt [email protected]:/backup
mydata.txt                                    100%   11     0.0KB/s   00:00

If he wanted to copy entire contents of directory called backup on server2 back to server 1, he would enter:

[[email protected]]$ scp -r [email protected]:/backup /backup
mydata.txt                                    100%   11     0.0KB/s   00:00
mydata1.txt                                    100%   11     0.0KB/s   00:00

scp command with SSH certificate

If you wanted to remote file copy without password authentication for automate your tasks or automate backup, you can uses SSH certificate. For above example, type the following command:

scp -r -i /path_to_private_key [email protected]:/backup /backup

For more information about scp command

At the prompt enter:

man scp

Related Posts:

{ 1 comment… read it below or add one } November 25, 2013 at 9:04 pm

Generally I don’t learn post on blogs, but I wish to say that this write-up very forced me to check out and do so! Your writing taste has been amazed me. Thank you, quite great post.


Leave a Comment

Previous post:

Next post: