There are several problems with the solution your proposing in my opinion. The biggest problem is that your solution is non-portable. Most hosts don’t have PHP’s SSH2 extension installed. And even if they do…

PHP’s SSH2 extension requires the private key and the public key both live on the filesystem. phpseclib accepts the key as a string and only needs the private key – not the public key (the public key can usually be extracted from the private key).

phpseclib supports keyboard-interactive authentication, as well, and is overall more reliable. With PHP’s SSH2 extension, you do ssh2_exec and you may get ANSI escape codes back. phpseclib doesn’t do this unless you’re using the interactive read() / write(). Which, right there, is another advantage phpseclib has over PHP’s SSH2 extension – interactive mode.

]]>By: David Rhttps://www.sitepoint.com/using-ssh-and-sftp-with-php/#comment-18979
Thu, 10 Jan 2013 20:16:20 +0000http://www.sitepoint.com/?p=4857#comment-18979How would you run a system command. Like cd’ing into a directory and tarball’ing all the files in it.