ssh2_connect在debian上未定义


ssh2_connect is undefined on debian

我在debian 6.0.8中有几个服务器,php版本为5.3.28-1~dotdeb.0。

我在每台机器上都做了一个apt-get安装libssh2php。当你创建php-v时,我在每个的列表中都有openssl和ssh2。之后我已经重新启动了apache。

但是,当我使用ssh2_connect()调用运行php脚本时,它在两台服务器上不起作用,但在另一台服务器上起作用。

我有一个错误:"调用未定义的函数ssh2_connect()。"

我不明白,debian版本和php版本是一样的。你能帮我吗?谢谢

在像Debian和EL这样的打包发行版中,PHP的"非核心"部分是单独打包的。在Debian风格中,您必须安装php5-sh2包。

sudo apt-get安装php5-sh2

我只想使用phpseclib,一个纯PHP SSH实现。例如

<?php
include('Net/SSH2.php');
$ssh = new Net_SSH2('www.domain.tld');
if (!$ssh->login('username', 'password')) {
    exit('Login Failed');
}
echo $ssh->exec('pwd');
echo $ssh->exec('ls -la');
?>

phpseclib比libssh2有很多优点。如果您愿意,也可以使用phpseclib来模拟libssh2函数。例如

https://github.com/phpseclib/libssh2-compatibility-layer