View Single Post
  #3  
Old 10-22-2008, 12:44 PM
unix unix is offline
Junior Member
 
Join Date: Sep 2009
Posts: 0
Default Re: SSH client insists on /dev/tty

Stephan Mann wrote:
> debug1: read_passphrase: can't open /dev/tty: No such device or address

[...]
> Obviously, /dev/tty *does* exist and has the proper permissions:
> sh-3.2# ls -l /dev/tty
> crw-rw-rw- 1 sysload 0 5, 0 Oct 21 15:01 /dev/tty


/dev/tty is defined to point to the "controlling terminal" of
whatever process tries to open it. Some processes have no
controlling terminal, in which case they will receive an ENXIO error
when trying to open /dev/tty - which is what you're seeing above.
The presence or absence of the special file itself is not the point.

The trouble is that "controlling terminal" never quite means what
you think it means. In particular, it need not bear any relation to
the terminal device that your process has open on fds 0, 1 and 2:
even if all those fds point to the same terminal device, your
official controlling terminal is at liberty to be something else, or
nothing at all.

> The shell running in this terminal is using /dev/console, although ps
> doesn't seem to get this right:
>
> sh-3.2# ps
> PID TTY TIME CMD
> 717 ? 00:00:00 sh


ps _is_ getting it right: it's showing you - accurately - that your
official controlling terminal is not set, even though all your file
descriptors are what you want them to be.

If I needed to solve this problem, I'd use a small utility of my own
which allocates a pseudo-terminal and runs a subprocess inside it.
Unfortunately, I've never got round to publishing that utility
properly on my website, but if you can access Subversion servers you
should be able to get hold of it by checking out

svn://svn.tartarus.org/sgt/filter

and running "make nullfilter". Then, if you run the resulting
nullfilter binary, it will start a subshell which should have a
sensible controlling terminal. Alternatively, running
"nullfilter -- ssh " will cause nullfilter to wrap just
the ssh command itself.

(I never really intended nullfilter to be a useful program in its
own right; the rest of that source directory is full of filter
programs which run things in ptys and interfere in various ways with
their I/O. nullfilter is the trivial member of that class of
programs, since it doesn't interfere with the I/O at all, but
curiously I keep finding uses like this one for it. Never neglect
the trivial case!)
--
Simon Tatham "Every person has a thinking part that wonders what
the part that isn't thinking isn't thinking about."
Reply With Quote