0

を呼び出すssh2_auth_noneと が返されるシナリオがありますtrue。ドキュメントによると、これは、認証なしでログインできるようにスイッチが構成されていることを示しているようです。

しかし、そうではありません。パスワードを使用しています...

私のコードは次のようになります。

<?php
$connection = ssh2_connect('10.124.123.45', 22);

$auth_methods = ssh2_auth_none($connection, 'username');
var_dump($auth_methods);

if (in_array('password', $auth_methods)) {
       echo "Server supports password based authentication\n";
}
?>

この問題を解決するために私がテストまたは確認できることについて、アイデアやコメントがあれば教えてください。ssh2_connect最終的には、このスイッチに電話しssh2_auth_password()てログインできるようにしたいと考えています。

ありがとう。

4

1 に答える 1

0

これらのタイプのスイッチへの接続方法を変更する必要がありました。問題の根本的な原因は、このスイッチの ssh の実装が非常に限られているため、phpseclib などの一般的なライブラリが機能しないことでした。

これが動作するコードです。CISCO のスモール ビジネス クラス スイッチに接続しようとしている他の人に役立つ場合があります。

  <?php
      $uname = 'myusername';
      $pswd = 'mypassword';
      $connection = ssh2_connect('123.123.123.123', 22);
      //$authentication_methods = ssh2_auth_none($connection, 'user');
      $stdio_stream = ssh2_shell($connection);
      fwrite($stdio_stream,$uname."\n");
      sleep(1);
      fwrite($stdio_stream,$pswd."\n");
      sleep(1);
      echo "Results: " . stream_get_contents($stdio_stream); 
      echo 'sending show bonjour command:<br>';
     fwrite($stdio_stream, "show bonjour".PHP_EOL);
     sleep(1);
     echo "<br>Results: " . stream_get_contents($stdio_stream); 
  ?>
于 2012-11-15T14:58:31.193 に答える