Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to use file transfer via SSH on some scripts. I've read it's possible to tar over ssh. Where should I start reading?

share|improve this question
    
Why do you bring up tar? –  Zoredache Mar 9 '10 at 19:37
1  
tar is the fastest way to copy files over SSH. scp and rsync have a lot of protocol overhead when copying lots of small files. –  Justin Mar 9 '10 at 21:12
    
@Justin, of course the assumption with tar is that you will have a reliable connection. If raw performance doesn't matter then it is usually better to stick with the more common and simple solutions like scp/rsync. –  Zoredache Mar 9 '10 at 22:04
1  
huh? tar over ssh is no worse then scp or rsync. The only aspect in which rsync is better is that it lets you resume. If the connection isn't reliable it is probably still worth it to try tar over ssh first, and then finish the transfer with rsync. –  Justin Mar 9 '10 at 22:10
    
@Justin, that would make a fairly complex script. Perhaps we should start with something just a little more basic. –  John Gardeniers Mar 10 '10 at 1:42
add comment

4 Answers

up vote 21 down vote accepted

To do file transfer over ssh you can

  • use scp
    • scp -r /srcdir/ user@remotehost:/destdir/
  • use rsync over ssh (see the -e parameter)
    • rsync -e ssh -a /srcdir/ user@remotehost:/destdir/
  • use some tool that transfers data via stdin/out (tar, cpio, etc)
    • cd /sourcedir; tar -c . | ssh username@remotehost bash 'cd /dstdir; tar -x
  • Mount the filesystem via sshfs (if fuse is supported on your system)
share|improve this answer
    
Pure awesomeness, thanks!! –  Fernando Briano Mar 10 '10 at 20:28
    
I regularly use all three; which one I use depends on the circumstances. –  reinierpost Mar 11 '10 at 14:22
add comment

O'Reilly has a book with it all - SSH, The Secure Shell: The Definitive Guide - if you Google for it, there are many references, places to buy it, and view it online.

share|improve this answer
    
Gotta love it when you get downvoted and no comments to let you know why. He asked where to start reading - and this is available online and from a bookstore. It is a great reference for ssh. –  Kevin K Mar 22 '10 at 18:38
    
I think this is wrong too. Why did you get voted down (twice) given that you actually answered the question and the accepted answer (voted up 15 times so far) is a generic how to copy files over ssh with no reference to where to start reading. I'm gonna vote you up, just to try to remedy the situation. Don't let them get you down man. –  Richard Holloway Mar 25 '10 at 23:52
add comment

Im no expert, but I think http://en.wikipedia.org/wiki/Secure_copy is what you want.

share|improve this answer
add comment

For tar over ssh, you can use the fact the ssh forwards stdin and stdout. So you can do

ssh server 'tar czf - /some/dir/' > tarfile.tar.gz

and have the backup on the local machine.

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.