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

Link to comment
Share on other sites

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.

Edited by kicken
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.