[sf-lug] how to get a program (e.g. shell script) to log in: e.g. respond to the password prompt?
Justin Ryan
justizin at vongogo.org
Sun Aug 24 10:12:19 PDT 2008
It's worth noting that there is a tool specifically for this purpose:
expect!
http://expect.nist.gov/
I'm actually not versed in expect, but I know when I was in Rackspace
engineering, expect was used by a friend to automate the installation
of things like FreeBSD with no automation a la kickstart. Something
I've been meaning to learn for a while and actually after looking over
the docs today I'm thinking about using it as the basis for network
service check scripts.
best!
j
On Sun, Aug 24, 2008 at 8:34 AM, jim <jim at well.com> wrote:
>
> 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
>>
>
>
> _______________________________________________
> sf-lug mailing list
> sf-lug at linuxmafia.com
> http://linuxmafia.com/mailman/listinfo/sf-lug
>
--
Justin Alan Ryan
Independent Interaction Architect
http://www.bitmonk.net/
* : +1-415-226-1199 x2600
"All because of a bunch of stuff that happened.."
-Homer Simpson
"The best way to get in touch with me is PayPal.
-Alexander Limi
More information about the sf-lug
mailing list