From: Paul Duncan Date: 2002-06-25T02:45:28+09:00 Subject: Re: How to use SSH from the cmd line in Ruby? * Nikodemus Siivola (tsiivola@cc.hut.fi) wrote: > > On Sat, 22 Jun 2002, Richard wrote: > > > Since an SSH package for Ruby doesn't exist right now, I have been > > trying to implement an SSH client through Ruby by sending text > > directly to the command line and retrieving the results. It's not > > working, though. > > Just guessing, but I believe ssh implementations typically connect > directly to the tty in use for password/phrase queries for security. Yup. openssh-3.3p1/readpass.c:100 rppflags = (flags & RP_ECHO) ? RPP_ECHO_ON : RPP_ECHO_OFF; if (flags & RP_ALLOW_STDIN) { if (!isatty(STDIN_FILENO)) use_askpass = 1; } else { rppflags |= RPP_REQUIRE_TTY; ttyfd = open(_PATH_TTY, O_RDWR); if (ttyfd >= 0) close(ttyfd); else use_askpass = 1; } > This means that you need to use tools like expect or open a pty. Another > option would be to use keypairs that do not require passphrases, or a > daemon that supplies the passphrase provided it has already been provided > once. > > The last option is AFAIK the secure & "correct" one. Look into ssh-agent. > > The basic idea is to start the daemon and supply it manually with the > passphrase, which it stores in memory. After this the daemon supplies the > information for all future connections. > > -- Nikodemus -- Paul Duncan pabs in #gah (OPN IRC) http://www.pablotron.org/ OpenPGP Key ID: 0x82C29562