This is a really useful tip, and it has infinite uses in a *nix environment. You can pipe data over SSH, from both a client and a server, and process it on the other side. This is pretty useful as it avoids the requirement to have the hard disk space to store a file before it is imported. Here’s a few examples:
Copying a remote database to a local database
ssh user@server-domain.com 'mysqldump -u root --password=passwordhere remote-database-name-here | gzip -c' | gunzip | mysql -u root --password=passwordhere local-database-name-here
Copying a folder of files to a remote server
cd /path/to/dir/to/copy;
tar -cz . | ssh user@server-domain.com 'tar -C /path/to/remote/dir -xzv'
tar -cz . | ssh user@server-domain.com 'tar -C /path/to/remote/dir -xzv'
The two examples above have shown you using ssh on the left and right of the command. There’s plenty of other uses, see what you can do with it.
“ssh -C” automagically does gzip compression for you, makes the first command a little shorter.
Nice tip, Matthew. Thanks 🙂