PHP SSH2问题ssh2_connect [英] PHP SSH2 Problem ssh2_connect

查看:107
本文介绍了PHP SSH2问题ssh2_connect的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我从php.net上看了一个例子看php ssh2的工作原理



所以代码是



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

if (ssh2_auth_password($ connection,' username'' secret')){
< span class =code-keyword> echo 验证成功!\ n ;
} else {
die(' 身份验证失败......');
}
?>





我提供了错误的信息,它给了我一些错误,而不是告诉我身份验证失败。



错误是



警告:ssh2_connect():php_network_getaddresses:getaddrinfo failed:名称 service  not 已知  
/var/zpanel/hostdata/zadmin/public_html/whothehellcareswhatisthis/ssh2.php 2 警告:ssh2_connect():无法连接到
shell.example.com端口 22 2 警告:ssh2_connect上的 /var/zpanel/hostdata/zadmin/public_html/whothehellcareswhatisthis/login/ssh2.php中的关键字> ():无法连接到
/ var / zpanel / hostda中的shell.example.com ta / zadmin / public_html / whothehellcareswhatisthis / login / ssh2.php在线 2 警告:
ssh2_auth_password()期望参数 1 为资源,布尔给出 /var/zpanel/hostdata/zadmin/public_html/whothehellcareswhatisthis/login/ssh2.php
on line 4 身份验证失败...

解决方案

连接 = ssh2_connect(' shell.example.com',22);

if (ssh2_auth_password(


connection,' 用户名'' secret')){
echo 认证成功\\\
!;
} else {
die(' 身份验证失败......');
}
?>





我提供了错误的信息,它给了我一些错误,而不是告诉我身份验证失败。



错误是



警告:ssh2_connect():php_network_getaddresses:getaddrinfo failed:名称 service  not 已知  
/var/zpanel/hostdata/zadmin/public_html/whothehellcareswhatisthis/ssh2.php 2 警告:ssh2_connect():无法连接到
shell.example.com端口 22 2 警告:ssh2_connect上的 /var/zpanel/hostdata/zadmin/public_html/whothehellcareswhatisthis/login/ssh2.php中的关键字> ():无法连接到
/ var / zpanel / hostda中的shell.example.com ta / zadmin / public_html / whothehellcareswhatisthis / login / ssh2.php在线 2 警告:
ssh2_auth_password()期望参数 1 为资源,布尔给出 /var/zpanel/hostdata/zadmin/public_html/whothehellcareswhatisthis/login/ssh2.php
on line 4 身份验证失败...


  

So I have taken a example from php.net to see php ssh2 workings

so the code is

<?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

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...

解决方案

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

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...



这篇关于PHP SSH2问题ssh2_connect的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆