[sf-lug] how to get a program (e.g. shell script) to log in: e.g. respond to the password prompt?
jim
jim at well.com
Sun Aug 24 08:34:53 PDT 2008
thanks, pavel. this was more what i was looking for,
and helpful to know this kind of technique won't work
with ssh. i was hoping for some way to detect the
password prompt rather than just issuing sleep commands
and hoping for the best.
a note to those interested in the syntax: there are
two parts to the command, the part in parentheses
preceding the pipe | character and the part following.
the part preceding is all in parentheses, which puts
the whole sequence of commands in a sub-shell and
yields their output as input to the pipe to telnet.
i am, of course, ready to stand corrected.
jim
On Sat, 2008-08-23 at 18:11 -0700, Usr Bin Sh wrote:
> In bash you can use (and such sequence works for telnet, ftp):
>
> theuser=someuser
> pword=secrect
> tout=3
> (sleep ${tout}; echo ${theuser}; sleep ${tout}; echo ${pword}; sleep
> ${tout}; echo "pwd"; sleep ${tout}; echo "exit") | telnet
> host.name.com
>
> it doesn't work for ssh/scp, but may work for some legacy
> applications. And yes, as previously was noted:using ssh/scp with
> passwordless key is preferable.
> Search google "ssh passwordless key"
> e.g. this link has nice description:
> http://www.brandonhutchinson.com/Passwordless_ssh_logins.html
> --
> /usr/bin/sh.pavel
>
> > Message: 2
> > Date: Sat, 23 Aug 2008 08:28:24 -0700
> > From: Michael Paoli <Michael.Paoli at cal.berkeley.edu>
> > Subject: [sf-lug] how to get a program (e.g. shell script) to log in: e.g. respond to the password prompt?
> > To: sf-lug at linuxmafia.com
> > Message-ID: <1219505304.48b02c9837a72 at webmail.rawbw.com>
> > Content-Type: text/plain; charset=ISO-8859-1
> >
> >> 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
> > authenticate).
> >
> > references:
> > ssh(1)
> > ssh-keygen(1)
> > ssh-agent(1)
> > expect(1)
> > perl(1)
> > http://www.cpan.org/
> > apt-cache(1) (as in apt-cache search ...)
> > ...
>
> _______________________________________________
> sf-lug mailing list
> sf-lug at linuxmafia.com
> http://linuxmafia.com/mailman/listinfo/sf-lug
>
More information about the sf-lug
mailing list