ssh2_connect() HELP!

Hello:

I would like to ask for some light in regards to this small case:

I am in the task of creating an ssh connection to remote servers around the world, which all are within the same DNS network. Under normal circumstances, logging into the servers via ssh using a the user name and password works, the problem that I am facing is the following.

Under PHP ssh2_connect(), the tunnel is opened, but the authentication fails, now, after some testing, I turned the “PasswordAuthentication yes” option in the sshd_config file in two of my test units, and it was able to work correctly. The problem here is that I cannot change security settings on hundreds of servers for PHP to gain access,… If possible, I would like to see if someone here can assist me in figuring out an alternative way to create this connection successfully…

Errors shown:

Warning: ssh2_auth_password() [function.ssh2-auth-password]: Authentication failed for admin using password in

Warning: ssh2_exec() [function.ssh2-exec]: Unable to request a channel from remote host in

here is the test code I am using which works under the “PasswordAuthentication yes” turned on but not when it is off, although it is possible to connect to those servers via Terminal or Putty or Cigwin

Test Code:

<?php $usr1 = "testunit"; $usr2 = 'mnafmm02'; $usr = 'admin'; $pwd = 'password'; $connection = ssh2_connect($usr2, 22); $auth = ssh2_auth_password($connection,$usr, $pwd); $cmd = ssh2_exec($connection, 'ls -al\n'); sleep (1); echo "End of file"; ?>
Sponsor our Newsletter | Privacy Policy | Terms of Service