Gossamer Forum
Home : General : Perl Programming :

Perl SSH Expect Problem

Quote Reply
Perl SSH Expect Problem
Info - Running on Red Hat Linux release 9 (Shrike), with openssh-3.5p1-6, and perl-5.8.0-88

I am trying to create a Web Password Changer at my work place and I am running into a problem.

I must change the password on two different servers and one of them is the web server running the program. So using Perl and Expect I ssh into server1 (using the person's user id and password) and have no problem changing the password, using the passwd command. The second server (the web server, i will call it server2) is where I am running into problems. Something is going wrong with SSH, Perl, or Expect. Inorder to use the passwd command I must ssh from server2 back into server2 and in the middle of changing the password with the passwd command the program hangs and times out.

I am just spawning a command to ssh into the machine.

my $exp = Expect->spawn("ssh -l $user $server")
or die "Cannot spawn ssh: $!\n";


It is in a function so I am using the exact same code for both servers.



Things I have tried

Running the program from the command line I have moved the program from server2 to server1 and the password is changed on server2 but hangs in the middle of changing the password on server1 (ssh'ing into itself like above).

I have tried running from server2 - ssh into server1 change password and then ssh'ing from server1 back into server2 and the program still hangs in the middle of changing the password.

I have tried extending timeouts to 60 seconds and that doesn't work.

I have uploaded the Program, and the debugging for expect that prints to the screen when the program is running.

Thanks for the help,



Patrick

Last edited by:

tie571: Jul 8, 2003, 1:21 PM
Quote Reply
Re: [tie571] Perl SSH Expect Problem In reply to
Try simplifying it with:

ssh user@server1 passwd

and it will prompt you for ssh pass, then run through the old/new pass from passwd. Also, you may need to give it a terminal and use:

ssh -t user@server1 passwd

to make expect happy.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Perl SSH Expect Problem In reply to
The initial test seems to have worked using your idea. Hopefully it will continue to work after more testing.

Thanks,



Patrick