Course lectures : 1 of 1

Copying files and directories between two servers using ssh:scp

Last updated: 4th March 2013

copying files ssh scpssh scpcopying between servers sshshell copying files

Today we'll have a quick look at how we can copy files and folders between two servers via ssh using scp program.

In the examples below, please replace the [username] with the server username and [host-ip] with the server ip address / domain name.

Example 1
Copying files from the local machine to the remote server

scp /local/directory/file.zip [username]@[host-ip]:/remote/directory/file.zip

Example 2
Copying files from the remote server to the local machine

scp [username]@[host-ip]:/remote/directory/file.zip /local/directory/file.zip

Example 3
Copying the entire directory from the local machine to the remote server

scp -r /local/directory [username]@[host-ip]:/remote/directory

Example 4
Copying multiple files from the local machine to the remote server

scp file.txt another-file.txt [username]@[host-ip]:/remote/directory

COMMENTS

If you'd like to include code example please wrap your code within <pre><code> tags.


<pre>
<code>
function fullName(firstName, lastName)
{
    return firstName + ' ' + lastName;
}
</code>
</pre>