scp without using scp
Ever want to use scp to copy from standard input? Maybe you want to avoid writing out a large file before copying, or maybe you don’t have write permissions on the system you’re connected to… Here’s the solution:
tar -c "iwant/" | bzip2 -9 -c | ssh user@host 'cat >/home/user/iwant.tar.bz2'
This works because ssh is executing the command you give it on the target host and piping its stdin to that command’s stdin. Nifty!
Another option is to connect to a remote system and pull down files:
ssh user@host 'cd /home/user/ ; tar -c "iwant/" | bzip2 -9 -c' > iwant.tar.bz2
Advertisement