php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56373 Cannot authenticate over localhost?
Submitted: 2005-04-13 14:47 UTC Modified: 2008-12-20 12:40 UTC
From: jason at greenhell dot com Assigned:
Status: Not a bug Package: ssh2 (PECL)
PHP Version: 5.0.3 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jason at greenhell dot com
New email:
PHP Version: OS:

 

 [2005-04-13 14:47 UTC] jason at greenhell dot com
Description:
------------
For some reason, ssh2_auth_password() refuses to authenticate when connecting to localhost with ssh2_connect().  I've tried both the IP (127.0.0.1) and hostname.

Any ideas?  Is this a bug?

Reproduce code:
---------------
if ($ssh = ssh2_connect("127.0.0.1")) {
   if (ssh2_auth_password($ssh, "username", "password")) {
      // ...

Actual result:
--------------
Warning: ssh2_auth_password(): Authentication failed for poller using password in /path/to/script.php on line XXX


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-13 18:56 UTC] pollita@php.net
Your visit to IRC pretty much closes this one. :)

*** oweff (jason@greenhell.com) has joined channel #libssh2
<oweff> hi all, Pollita
<oweff> Pollita: nice work on the ssh2 bindings for php
<oweff> only i cannot get it to authenticate with a password over a connection to localhost
<oweff> ah n/m got it
*** oweff has left channel #libssh2 because ()
 [2006-07-06 05:36 UTC] iamhermes at gmx dot net
same problem. connect to localhost not possible.
connect to other server works.
phpscript:

<?php
$connection = ssh2_connect('localhost', 22);
if (ssh2_auth_password($connection, 'user', 'password')) {
  echo "Authentication Successful!\n";
} else {
  die('Authentication Failed...');
}
print_r($connection);

?> 

output php script:
Warning: ssh2_auth_password(): Authentication failed for ut2004 using password in /var/www/vhosts/bravo795.server4you.de/httpdocs/pages/UT2004.php on line 3
Authentication Failed...

log from ssh:
Jul  6 11:18:34 bravo795 sshd[22737]: Connection from ::ffff:127.0.0.1 port 56629
Jul  6 11:18:34 bravo795 sshd[22737]: debug1: Client protocol version 2.0; client software version libssh2_0.14 PHP
Jul  6 11:18:34 bravo795 sshd[22737]: debug1: no match: libssh2_0.14 PHP
Jul  6 11:18:34 bravo795 sshd[22737]: debug1: Enabling compatibility mode for protocol 2.0
Jul  6 11:18:34 bravo795 sshd[22737]: debug1: Local version string SSH-2.0-OpenSSH_3.8.1p1 Debian-8.sarge.4
Jul  6 11:18:34 bravo795 sshd[22737]: debug1: PAM: initializing for "ut2004"
Jul  6 11:18:34 bravo795 sshd[22737]: debug1: PAM: setting PAM_RHOST to "localhost.localdomain"
Jul  6 11:18:34 bravo795 sshd[22737]: debug1: PAM: setting PAM_TTY to "ssh"
Jul  6 11:18:34 bravo795 sshd[22737]: debug1: do_cleanup
Jul  6 11:18:35 bravo795 sshd[22737]: debug1: PAM: cleanup
Jul  6 11:18:35 bravo795 sshd[22670]: debug1: Forked child 22739.
 [2006-09-09 07:02 UTC] jef at junk dot not
Same problem for me... Is there still no solution for this 
problem (first report dates from more then a year ago...) 
or did I missed something?

I use Debian Stable for my server, had to 'cheat' somewhat 
at the installation of 'libssh2' (change some things in 
the src/Makefile (remove all <-o file.o> parts, add 
sometimes a '-I' at CFLAGS)) but I don't understand why 
this would allow me to connect to another PC and not to my 
localhost.
 [2006-09-14 11:53 UTC] pollita@php.net
Double check your sshd_config file.  90% of the time this is because the server is pre-configured by the distribution to disable password based authentication.  It *looks* like you're using password based when you're using the command line program, but it's actually keyboard-interactive (which is an entirely different authentication scheme).
 [2006-09-17 05:48 UTC] jef at junk dot not
Ok, thx pollita! 

I had to allow indeed 'PasswordAuthentication' in 
sshd_config. Now it works fine!
 [2008-12-20 12:40 UTC] mikesul@php.net
Expected behavior then.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 14:01:27 2025 UTC