|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61320 Problems with ssh2_auth_pubkey_file
Submitted: 2012-03-07 16:06 UTC Modified: 2012-06-14 21:42 UTC
From: joey at teehanlax dot com Assigned: langemeijer (profile)
Status: Closed Package: ssh2 (PECL)
PHP Version: 5.3SVN-2012-03-07 (SVN) OS: Ubuntu
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: joey at teehanlax dot com
New email:
PHP Version: OS:


 [2012-03-07 16:06 UTC] joey at teehanlax dot com
From manual page:

I've tried every possible combination to get this function to work.  I've ran tests on both rsa and dsa keys and have determined that this function must have a bug related that is preventing it from functioning properly.   I've tested and ensured that my php is running as the proper user and have also used the system command and ensured that i could make a connection from within the PHP file.

Test script:
system("ssh -i id_rsa");

The above will make a connection to the remote server. However below will not for both rsa and dsa keys:

$server = "";
$connection = ssh2_connect($server, 22, array('hostkey'=>'ssh-rsa'));
if (ssh2_auth_pubkey_file($connection, 'user', '~/.ssh/', '~/.ssh/id_rsa')) {
       echo "success!";
} else {
       echo "no success :-(";

I've also tried multiple combinations including adding a pass phrase and verifying permissions and also trying different connection servers.

Expected result:

Actual result:
PHP Warning:  ssh2_auth_pubkey_file(): Authentication failed for ubuntu using public key in /home/teehanlax/test-rsa.php on line 9
no success :-(


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-07 19:21 UTC]
-Package: *General Issues +Package: ssh2
 [2012-06-14 21:42 UTC]
This function does not allow ~ for home dir. Please specify the full path to the 
 [2012-06-14 21:42 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: langemeijer
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Nov 30 20:01:27 2020 UTC