Hi all,
I am trying to use PHP to do ssh authentication:
I have written an expect script that will do the job from the command line, then call it from exec(escapeshellcmd(sshauth $login $host $passwd),$r)the script worked fine over php3 but after upgrading to PHP4 it seems that it doesn't work anymore
the expect script
-----------
#!/usr/bin/expect -f

#log_user 0

spawn /usr/local/bin/sftp2 [ lindex $argv 0]@[lindex $argv 1]
expect {
"[lindex $argv 0]@[lindex $argv 1]'s password:"
{ send "[lindex $argv 2]r";
expect {
-re "[lindex $argv 0]@[lindex $argv 1]'s password:" {send_user "1";exit}
-re "sftp>" {send_user "0n";exit}
}
}
eof {send_user "1n";exit}
}
-------------
when I run it from the command line
./sshauth mylogin thehost mypasswd
gives me 0 on success and 1 on failure.
However,
when I call it using exec or passthru passthru(EscapeShellcmd ("/thepath/sshauth $login $host $passwd"));

I get:spawn /usr/local/bin/sftp2 @ Executing ssh2 failed. Command:' ssh2 -x -a -o passwordprompt %U@%H's password: -o nodelay yes -o authenticationnotify yes @ -s sftp' System error message: 'No such file or directory' Warning: child process (ssh2) exited with code 255.
(I used to see this message before using escapeshellcmd on php3, like escapeshellcmd is not working for me)
Anyone can help??