Jump to content

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

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.