I use this library http://phpseclib.sourceforge.net/ssh/intro.html to create a persistent ssh connection. I need to select a subsystem (which would be the -s
parameter in corresponding Unix ssh
command).
How can I achieve this?
Here is my code
$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'); }
The latest git version of phpseclib should support this. eg.
<?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();
This vim subsystem is defined by doing Subsystem vim /usr/bin/vim
in sshd_config.