title: PHP SSH2 save current session for repeatable commands
body: <p>I want to simulate SSH commands via PHP</p>
  
  <p>Currently i tried to use <strong>phpseclib</strong>:
  <a href="http://phpseclib.sourceforge.net/" rel="nofollow noreferrer">http://phpseclib.sourceforge.net/</a></p>
  
  <p>The code is:</p>
  
  <pre><code>$ssh = new Net_SSH2('184.170.248.68');
  
  if (!$ssh-&gt;isConnected() &amp;&amp; !$ssh-&gt;login('payton', 'lowe225')) {
      exit('Login Failed');
  }
  echo '&lt;pre&gt;';
  echo $ssh-&gt;exec('pwd');
  echo $ssh-&gt;exec('ls -la');
  echo '&lt;/pre&gt;';
  </code></pre>
  
  <p>Each time when i do request to script i must wait when authentication will be done.</p>
  
  <p>Is there any way to store SSH session and restore it on second PHP script call, to make script run faster?</p>
  
  <p>I know that better way is to develop server side application with API interface to do that in better way. But i want to know if in small task that can be achieved.</p>