Click here to Skip to main content
15,884,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So I have taken a example from php.net to see php ssh2 workings

so the code is

PHP
<?php
$connection = ssh2_connect('shell.example.com', 22);

if (ssh2_auth_password($connection, 'username', 'secret')) {
    echo "Authentication Successful!\n";
} else {
    die('Authentication Failed...');
}
?>


When I am putting wrong information it is giving me some error instead of telling me Authentication Failed.

The Error is

PHP
Warning: ssh2_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in 
/var/zpanel/hostdata/zadmin/public_html/whothehellcareswhatisthis/ssh2.php on line 2 Warning: ssh2_connect(): Unable to connect to 
shell.example.com on port 22 in /var/zpanel/hostdata/zadmin/public_html/whothehellcareswhatisthis/login/ssh2.php on 
line 2 Warning: ssh2_connect(): Unable to connect to shell.example.com in 
/var/zpanel/hostdata/zadmin/public_html/whothehellcareswhatisthis/login/ssh2.php on line 2 Warning: 
ssh2_auth_password() expects parameter 1 to be resource, boolean given in /var/zpanel/hostdata/zadmin/public_html/whothehellcareswhatisthis/login/ssh2.php 
on line 4 Authentication Failed...
Posted

1 solution

PHP
$connection = @ssh2_connect('111.111.111.111', 22);

if (@ssh2_auth_password($connection, 'root', 'password')) {
    echo "Authentication Successful!\n";
} else {
    die('Authentication Failed...');
}
?>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900