我想从RHEL ssh到SLES机器。我使用PHP函数ssh2来实现这一点。即使传递正确的用户名和密码,身份验证也不会发生。但是相同的代码对于RHEL-> RHEL工作正常。我可以从RHEL终端ssh到SLES机器。但使用ssh2不会发生。ssh2不适用于suse
<?php
if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist");
// log in at ip on port 22
if(!($con = ssh2_connect(ip, 22))){
echo "fail: unable to establish connection\n";
} else {
// try to authenticate with username root, password password
if(!ssh2_auth_password($con, "root", "password")) {
echo "fail: unable to authenticate\n";
} else {
// allright, we're in!
echo "okay: logged in...\n";
// execute a command
if (!($stream = ssh2_exec($con, 'date'))) {
echo "fail: unable to execute command\n";
} else {
// collect returning data from command
//echo "in else";
stream_set_blocking($stream, true);
$data = "";
while ($buf = fread($stream,4096)) {
$data .= $buf;
}
echo $data;
fclose($stream);
}
}
}
?>
我得到的输出“失败:无法验证”。为什么会发生这种情况?任何解决方案?
这是工作!:)不过我还是想不出弄清楚为什么SSH2不是为RHEL-工作> SLES。不管怎样,谢谢 :) – Akshatha