I have a scenario where when i call ssh2_auth_none
, it returns true
. According to the documentation, it would seem to indicate that this means the switch is configured to allow login without authentication.
However, this is not the case. We are using passwords...
Here's what my code looks like:
<?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";
}
?>
Just wondering if you have any ideas or comments on what I can test or check to resolve this issue. Ultimately, I'd like to be able to call ssh2_connect
and ssh2_auth_password()
to login to this switch.
Thanks.
We had to change the way we connect to these types of switches - the root cause of the problem was that this switch has a very limited implementation of ssh and so popular libraries like phpseclib don't work.
here's our code that works - in case it helps anyone else out there who's trying to connect to CISCO's small business class switches.
<?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);
?>