2013-10-24 26 views
1

我使用这个库http://phpseclib.sourceforge.net/ssh/intro.html创建一个持久的ssh连接。我需要选择一个子系统(这将是相应的Unix ssh命令中的-s参数)。php ssh连接:select子系统

我该如何做到这一点?

这里是我的代码

$this->ssh = new Net_SSH2($this->host, $this->port); 
$key = new Crypt_RSA(); 
$key->loadKey(file_get_contents($this->key)); 
if (!$this->con->login('username', $key)) { exit('Login Failed'); } 
+0

Net/SFTP实现了sftp子系统。你试图利用哪个子系统?如果您可以发布该子系统的'sshd_config' config的相关部分,让我测试发布之前可能给出的任何响应。我有一些想法,但想先测试。谢谢! – neubert

+0

我想创建一个连接到远程服务器上的某个接口。我不确定,但我不认为我可以访问子系统的sshd_config .. –

回答

0

phpseclib最新Git版本应该支持这一点。例如。

<?php 
include('Net/SSH2.php'); 

$ssh = new Net_SSH2('127.0.0.1'); 
$ssh->login('username', 'password'); 

$ssh->setTimeout(5); 

$ssh->startSubsystem('vim'); 
echo $ssh->read(); 

这个vim子系统是通过在sshd_config中做Subsystem vim /usr/bin/vim定义的。