I want to download files from a remote server to my local drive, and do it from the command line. I also want to be able to do this over SSH. How can I do this?

Note: the remote server is Ubuntu, the local is Mac OS X

link|improve this question

65% accept rate
feedback

4 Answers

up vote 10 down vote accepted

Use scp-command, it runs on top of ssh. Example:

scp username@remote.host:/path/to/file localfile

It also works another way round

scp localfile username@host:/path/remotefile

Username, path, and filename can be omitted (but not the : !).

As Iain said, sftp works also, but I tend to favor scp for its cp-like usage.

link|improve this answer
Less common I'm sure, and correct me if I'm wrong, but I think scp also works remote-to-remote, if you really need to: scp username@remote1:/path/to/file username@remote2:/path/to/file – JMD Jan 11 '10 at 22:06
can you copy directories? – Andrew Jan 11 '10 at 22:10
figured it out... -r recursively copies directories too – Andrew Jan 11 '10 at 22:15
feedback

I use sftp for this. It's command line and uses the same security as ssh.

link|improve this answer
feedback

You can also use rsync for it. It can work over ssh.

link|improve this answer
feedback

If you can't use scp or sftp you can use tar over ssh:

tar cf - . | ssh otherhost "cd /mydir; tar xvf -"

This one is also good if you have sparse files which otherwise will "explode".

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.