[San-Diego-pm] Output Remote File Descriptors

Tkil tkil-sdpm at scrye.com
Thu Nov 11 17:01:47 CST 2004

>>>>> "Steve" == sandrewz  <sandrewz at yahoo.com> writes:

Steve> I'm wondering if it is possible to capture a file descriptor
Steve> from a remote machine via ssh and use that information locally.

File descriptors in the traditional sense only make sense to one
process on a given machine.  There are ways to pass descriptors
between processes on a single machine (more precisely, any single
system image) but since they are effectively indexes into kernel
structures, it wouldn't do much good to take a descriptor (which is,
really, just an integer) to another machine.

What are you actually trying to accomplish?

'ssh' itself redirects its input and output streams appropriately, so
you can do things like:

   ssh remotehost 'cat > /tmp/from-elsewhere.txt' < stuff.txt

(Occasionally complicated by the need to read passwords, but that's
usually handled either by ssh opening the tty and reading from that
(instead of from "standard input" in the usual sense) or by using
private keys so that you don't need passwords at all.)

You can also use 'ssh' to redirect ports off one machine to another.
If you don't have firewalling and don't need encryption, you can do
that with 'nc' ("netcat").

A typical example of the former is using IRC over an
SSH tunnel:

   ssh remotehost -L6667:irc.mozilla.org:6667

This initiates a shell on remotehost, but also listens on local (thus
the "-L") port 6667; whenever someone connects to that port, sshd on
remotehost connects to irc.mozilla.org port 6667 and proxies the

For the latter, I've done stuff like this to quickly transfer files
from one machine to another.  On the server, I type this and it waits
for a connection...

   server$ nc -l -p 3000 | tar xvf -

Which I provide on the local host like so:

   local$ tar cvf - .... | nc server 3000

If you actually have state on a local connection that you want to
transfer to a different machine, there is no way I know of doing so.
(There are some exotic options, but if you were involved with that
stuff [message passing; single system image; NUMA; etc], you'd already
know about them.  :)


More information about the San-Diego-pm mailing list