Page 1 of 1

help with php + ssh

Posted: Sat Oct 25, 2008 12:32 pm
by vitid
hi, i have problem about php using ssh

the problem is that i don't know how to respond to server's authentication request.

for example : i use grid-proxy-init command and server will request me to enter the passphrase key

(just to note that i didn't get a problem with login to server , i can login successfully but i don't know how to respond to server's request)

here is my code:

<?php


if(!($con = ssh2_connect("xxxxxxxxx", 22))){
echo "fail: unable to establish connection\n";
} else {

if(!ssh2_auth_password($con, "xxxx", "xxxxx")) {
echo "fail: unable to authenticate\n";
} else {

echo "okay: logged in...\n";



$cmd = 'grid-proxy-init -cert cert.pem -key userkey.pem';
//execute grid-proxy-init command and server will request me to type passphrase(password)
if(!($stream = ssh2_exec($con,$cmd)) ){
echo "fail: unable to execute command\n";
} else{
//here i can't get this to work , it act like i just login
//for example : if i type password = ls , it will display
//all file in directory ; instead of recognize it as passphrase
$stream = ssh2_exec($con,'password');
stream_set_blocking( $stream, true );

echo stream_get_contents($stream);

fclose($stream);

echo "success";
}


}
}
?>

i try googling for 3 hours and can't find any answer :(

very thank for your help and reply :) :)

Re: help with php + ssh

Posted: Sat Oct 25, 2008 12:47 pm
by Hannes2k
Hi,
why doesn't ssh2_auth_password() work?

Re: help with php + ssh

Posted: Sat Oct 25, 2008 12:56 pm
by vitid
Hannes2k wrote:Hi,
why doesn't ssh2_auth_password() work?
no , i mean , i can login successfully , my problem is to answer the server request :
it request me to enter the passphrase(password) for grid-proxy-init command that i send

//execute grid-proxy-init command and server will request me to type passphrase(password)
if(!($stream = ssh2_exec($con,$cmd)) ){
echo "fail: unable to execute command\n";
} else{
//here i can't get this to work , it act like i just login
//for example : if i type password = ls , it will display
//all file in directory ; instead of recognize it as passphrase
$stream = ssh2_exec($con,'password');

Re: help with php + ssh

Posted: Sat Oct 25, 2008 1:07 pm
by Hannes2k
Hi,
hmm one solution would be not to encrypt the key (userkey.pem), so grid-proxy-init don't ask you for the password of it.