简体   繁体   English

使用phpseclib Net_SSH2的PHP SSH连接

[英]PHP SSH conection using phpseclib Net_SSH2

I'm trying to get remote ssh working on my website (hosted with godaddy). 我正在尝试使远程ssh在我的网站(由godaddy托管)上工作。

I have downloaded and placed the phpseclib onto the server and it is seeing it, I am using to following code as recommended by the documentation 我已经下载了phpseclib并将其放置到服务器上,并且可以看到它,我习惯于按照文档推荐的方式执行以下代码

<?php

set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
include('Net/SSH2.php');
define('NET_SSH2_LOGGING', NET_SSH2_LOG_COMPLEX);

echo "<span>in progress: <br /></span>";

$ssh = new Net_SSH2('197.87.71.51', 2211);

if (!$ssh->login('postgres', 'postgres')) {
    exit('Login Failed');
} else {
    echo "<span>login success<br /></span>";
}

echo $ssh->exec('pwd');
echo $ssh->getLog();
echo $ssh->getLastError();

?>

I am getting the login failed message and I dont know where to start with debugging this. 我收到登录失败消息,并且我不知道从哪里开始调试。

I'm not getting any error messages it doesn't really look like anything is happening 我没有收到任何错误消息,看起来好像没有发生任何事情

Try to see the errors 尝试看看错误

 print_r($ssh->getSFTPErrors());

or just 要不就

$ssh->getErrors()

Chapter 5.1.8. 第5.1.8章。 Debugging SSH-2 in the documentation 文档中的SSH-2调试

include('Net/SSH2.php');
define('NET_SSH2_LOGGING', NET_SSH2_LOG_COMPLEX);

$ssh = new Net_SSH2('www.domain.tld');
if (!$ssh->login('username', 'password')) {
    exit('Login Failed');
}

echo $ssh->exec('pwd');
echo $ssh->getLog();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM