2013-10-24 27 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定義的。