Jump to content

Having Probelm With Ssh2_Exec()


dodul

Recommended Posts

Hi,

 

I have the below code to get tput from a remote server,

 

$connection = ssh2_connect('x.x.x.x', 22 );
if( !$connection )die( 'Can not Connect' );
if( ssh2_auth_password( $connection, 'user', 'pass' ) )
{
echo "Password Correct<br/>";
}else{
echo "Password Wrong<br/>";
}

$out = ssh2_exec( $connection, 'ls ');
echo $out;
$err_stream = ssh2_fetch_stream( $out, SSH2_STREAM_STDERR );
$result_err = stream_get_contents( $err_stream );
echo $result_err;
stream_set_blocking( $out, true );
while( $line = fgets($out) ){
flush();
echo $line;
$content.=$line;
}

 

 

This code runs and outputs perfectly to my server if connected to the root user account. However, if I try to connect to other user accounts no output is shown. Again if I connect to my server using putty to the same user account and exicute the same command it shows output. Can anyone give me idea what can be the possible issue for this?

 

Thanks in advanced.

Link to comment
https://forums.phpfreaks.com/topic/271245-having-probelm-with-ssh2_exec/
Share on other sites

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.