stdout
on one CentOS server needs to be piped to stdin
on another CentOS server. Is this possible?
Update
ScottPack, MikeyB and jofel all have valid answers. I awarded the answer to Scott because, even though my question didn't specify security as a requirement, it's always nice to be safe. However, the other two fellows' suggestions will also work.
Best Answer
This is an unabashed yes.
When one uses
ssh
to execute a command on a remote server it performs some kind of fancy internal input/output redirection. In fact, I find this to be one of the subtly nicer features of OpenSSH. Specifically, if you usessh
to execute an arbitrary command on a remote system, then ssh will mapSTDIN
andSTDOUT
to that of the command being executed.For the purposes of an example, let's assume you want to create a backup tarball, but don't want to, or can't, store it locally. Let's have a gander at this syntax:
We're creating a tarball, and writing it to
STDOUT
, normal stuff. Since we're using ssh to execute a remote command, STDIN gets mapped to theSTDIN
ofcat
. Which we then redirect to a file.