You can - via multiple SSH pipes.
For example:
ssh user@host1 "mysqldump -u [user] -p[pwd] --no-create-db --no-create-info [db] [table] | gzip -c" | ssh user@host2 "gzip -c -d | mysql -h [host] -u [user] -p[pwd]"
Breaking this down a bit, you have two SSH commands, piped to each other:
- The first one runs the
mysqldump
, then pipes the result to gzip
, which in turns sends the result to STDOUT.
- The second command takes STDIN and decompresses it, then pipes it to the
mysql
command.
When you combine the two commands, you can pass data between two hosts directly using SSH.
Example in practice below:
cwatson@zeus:~$ ssh tyr
cwatson@tyr:~$ echo stuff123tyr > testfile.txt
cwatson@tyr:~$ cat testfile.txt
stuff123tyr
cwatson@tyr:~$ logout
ssh tyr "cat ~/testfile.txt | gzip -c" | ssh thor "gzip -c -d > ~/testfile.txt"
cwatson@zeus:~$ ssh thor
Last login: Fri Feb 26 17:28:01 2016 from host217-44-218-9.range217-44.btcentralplus.com
cwatson@thor:~$ cat testfile.txt
stuff123tyr