SSH2连接无法使用php虽然我确定我将其安装在我想用来连接远程服务器的服务器上
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
if (!($con = ssh2_connect("ip_goes here", 22))) {
die('<div style="color:#333;font-size:18px">Server not reachable.Error 1002 </div>');
}
echo "ssh2_connect finally works";
?>
我收到了Server not reachable.Error 1002
和Warning: ssh2_connect(): Unable to connect to ip_goes_here on port 22
顺便说一句,我尝试使用putty通过端口22连接到ip,它工作正常。如果ssh2_connect
不存在,我会得到Undefined function error
修改 我能够通过ssh罚款
连接到ipssh root@xxx.xx.xxx.xxx
The authenticity of host 'xxx.xx.xxx.xxx (xxx.xx.xxx.xxx)' can't be established.
RSA key fingerprint is 3a:8b:14:a8:10:09:0a:2f:1a:c4:3b:c7:97:56:42:6e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'xxx.xx.xxx.xxx' (RSA) to the list of known hosts.
答案 0 :(得分:1)
问题在于selinux,我不得不禁用ssh2来连接