Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question
add comment

4 Answers

up vote 21 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.

share|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
add comment

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

share|improve this answer
add comment

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

share|improve this answer
add comment

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".

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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