Search the Community
Showing results for tags 'ssh2'.
-
Provider changed there security settings and now I am not able to connect. I get this error "ssh2_connect(): Error starting up SSH connection(-5): Unable to exchange encryption keys " these are the keys they except now. how to I tell ssh_connect() to use one of these try { $connection = ssh2_connect($db['cit_host'], $port); if(!$connection){ throw new \Exception("Could not connect to $host on port $port"); } $auth = ssh2_auth_password($connection, $user, $pass); if(!$auth){ throw new \Exception("Could not authenticate with username $user and password "); } $sftp = ssh2_sftp($connection); if(!$sftp){ throw new \Exception("Could not initialize SFTP subsystem."); } $stream = fopen("ssh2.sftp://" .(int)$sftp.'//Inbox//'.$remoteFile, 'w'); if (! $stream) { echo "<td>$sftp$remoteFile</td>"; throw new \Exception("Could not open file: "); } $file = file_get_contents($remoteFile); if (fwrite($stream, $file) ===FALSE){ echo "File Not Written";
-
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.