Jump to content

Problem ssh login from PHP webapp using expect script


sndpkol

Recommended Posts

Hi ALL,

I m using a Php program ,which on click triggers a shell script ,with in which it try to ssh to remote host and login.. to pass the password for ssh to remote host ,i m using expect script(whihc supplies the password)

when i run this script through shell command line it works perfectly.but when i use the php web program it is not working .the expect script triggers ssh to remote host but password is not supplied .

 

expect script which is triggered by shell script

 

#!/usr/bin/expect

spawn ssh -t IPAddress

expect "*?assword:*"

send "password\r"

interact

 

PHP script

<?php

 

passthru('/<pathto script>/wrapper.exp>wrapper.log');

 

?>

~

 

the above php is triggered by html for on click

 

 

Thanks in advance

Regards,

Sandeep M

I'm not to familiar with expect, so I can't help much there.  However I have a few alternative suggestions you could implement instead of using expect:

 

a) Try using the SSH2 extension for PHP to connect and do what you need from within PHP rather than attempting to exec() an external utility or 

b) Setup public-key based authentication to allow you to login without needing to enter in a password.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.