[sf-lug] how to get a program (e.g. shell script) to log in: e.g. respond to the password prompt?

Michael Paoli Michael.Paoli at cal.berkeley.edu
Sat Aug 23 08:28:24 PDT 2008

> Date: Fri, 22 Aug 2008 10:03:06 -0700
> From: Rick Moen <rick at linuxmafia.com>
> Subject: Re: [sf-lug] perl backup script, and other perl goodies
> To: sf-lug at linuxmafia.com
> Quoting Asheesh Laroia (asheesh at asheesh.org):
> > On Fri, 22 Aug 2008, jim wrote:
> > >   how to get a program (shell script most likely
> > > in my case) to log in: i.e. issue a
> > > scp <file> <user>@<host>:<dir>
> > > command and then respond to the password prompt?
> > Public key authentication.  See http://apt-get.dk/howto/backup/.
> I have more about that technique here:  "SSH Public-Key Process" on
> http://linuxmafia.com/kb/Security/

Yes, public key authentication would typically be the preferred method.
One would typically want to have the private key well secured and
protected, including being encrypted with a strong passphrase - at least
if that latter part is feasible for the intended usage.

Another possible approach is expect.  Some other languages, etc. (e.g.
perl, tk), and also some utilities/programs (such as those originally
designed for serial communications, such as some uucp and ppp software)
also have expect modules or the equivalent, or expect or expect-like
capabilities.  The disadvantage with the expect type approach, is that
one must somehow get expect to issue the clear text password in response
to the password prompt (at least if that's how one is going to

apt-cache(1) (as in apt-cache search ...)

More information about the sf-lug mailing list