Monday, October 8, 2007

Secure Copy

scp is like cp for copying files only it can securely copy files from one server to another using the ssh protocol. This is a good thing. The bad thing is that I always forget how to write the line, because I'm a ditz that way.

Here's an example of how to copy a file from a local computer to a location on a remote server:
scp index.php user@web2.websites.com:/mysite.com/httpdocs/index.php

Here's an example of how to copy a whole directory from a local computer to a remote server:
scp -r httpdocs/. user@web2.websites.com:/mysite.com/httpdocs/.

Notice the slash dot thing at the end of the directory name. That's so that everything under that directory gets moved. If you don't use the slash dot after the directory name you will end up with the directory inside the other directory (like /mysite.com/httpdocs/httpodocs/...) which is clearly not what I want.

The -r stands for recursive.

Of course, you can find more details about other options that go with scp by typing
man scp
at a linux-ish or unix-ish command prompt.

No comments: