aluminumpork Posted September 29, 2007 Share Posted September 29, 2007 I finally got the SSH2 PHP extension installed and working properly and have played around with some of the functions and also a couple of classes that simply things. However, I guess I'm still a bit confused as to how to connect to your standard fare Linux box and actually get something done. For instance, most of the SSH2 classes wrap the ssh2_connect and ssh2_auth_password functions together, so you can do something like this: $ssh->connect($host, $user, $pass, $port); However, this always fails with an authentication failed message, even though I -know- the information I provided is correct. I'm kind of at a loss as to where to go from here. My ultimate goal is to be able to connect, run a command, retrieve the results of the command and disconnect, which I have been able to do with a telnet class in PHP, without much issue. Due to the insecurity of Telnet however, I do not want to continue using it. Any help is greatly appreciated. Thanks. Quote Link to comment Share on other sites More sharing options...
isthisyournacho Posted April 18, 2008 Share Posted April 18, 2008 Have you tried NOT wrapping them to see what you get? if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist"); // log in at server1.example.com on port 22 if(!($con = ssh2_connect("server1.example.com", 22))){ echo "fail: unable to establish connection\n"; } else { // try to authenticate with username root, password secretpassword if(!ssh2_auth_password($con, "root", "secretpassword")) { echo "fail: unable to authenticate\n"; } else { // allright, we're in! echo "okay: logged in...\n"; } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.