简体   繁体   中英

PHP SSH conection using phpseclib Net_SSH2

I'm trying to get remote ssh working on my website (hosted with 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

<?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. Debugging SSH-2 in the documentation

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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