1

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 sshcommand).

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'); }
Oriesok Vlassky
  • 797
  • 1
  • 13
  • 26
  • Net/SFTP implements the sftp subsystem. What subsystem are you trying to utilize? If you could post the relevant portion of the `sshd_config` config for that subsystem that'd let me test any response I might give prior to posting it. I have a few ideas but would like to test first. Thanks! – neubert Oct 24 '13 at 16:11
  • well I want to create a connection to some interface on remote server. I am not sure, but I don't think I can access the sshd_config for the subsystem.. – Oriesok Vlassky Oct 25 '13 at 08:06

1 Answers1

0

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.

neubert
  • 15,947
  • 24
  • 120
  • 212