|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78661 ssh2_auth_pubkey_file(): Authentication failed using public key: Callback retur
Submitted: 2019-10-11 08:47 UTC Modified: 2019-10-11 09:40 UTC
Avg. Score:4.4 ± 1.1
Reproduced:13 of 16 (81.2%)
Same Version:7 (53.8%)
Same OS:10 (76.9%)
From: mistermadness at ya dot ru Assigned:
Status: Open Package: ssh2 (PECL)
PHP Version: 7.3Git-2019-10-11 (snap) OS: Debian 10
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2019-10-11 08:47 UTC] mistermadness at ya dot ru
PHP 7.3.9-1~deb10u1 (cli) (built: Sep 18 2019 10:33:23) ( NTS )

I have two virtual machines one Debian 9.3 and I connect successfully, another machine is Debian 10.1 and I recieve message ssh2_auth_pubkey_file(): Authentication failed for subscr using public key: Callback returned error.

Difference in libSSH version Debian 9.3 - libssh2/1.7.0, Debian 10 - SSH-2.0-libssh2_1.8.0

It looks like some problem with key auth.

Test script:
$this->connection = ssh2_connect($host, $port, array('hostkey'=>'ssh-rsa'));
if (ssh2_auth_pubkey_file($this->connection, $username, $rsapath, $rsapubpath)) {
  //echo "Public Key Authentication Successful\n";
} else {
  die('Public Key Authentication Failed');

Expected result:
Connect and recieve Public Key Authentication Successful

Actual result:
Warning: ssh2_auth_pubkey_file(): Authentication failed for subscr using public key: Callback returned error in /usr/local/nginx/html/cms/admin/classes/sshCron.php on line 18
Public Key Authentication Failed


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-10-11 09:40 UTC]
-Package: *Encryption and hash functions +Package: ssh2
 [2019-11-21 08:55 UTC] lukas dot zierer at abf dot ch
I have exactly the same issue with PHP 7.3.11-1~deb10u1 on Debian 10. The same script works with identical permissions on my .ssh directory and containing files on Debian 9.6 with PHP 7.1.26.
 [2020-08-07 11:47 UTC] andras dot kovacs at videosqr dot com
I have exactly the same problem. sshd debug as follows:

debug1: /home/myuser/.ssh/authorized_keys:1: matching key found: RSA SHA256:hzJgakOeZOqlCLD8Vo57PimTrqXtrgdCwpodT/vZvRw
debug1: /home/myuser/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
Accepted key RSA SHA256:hzJgakOeZOqlCLD8Vo57PimTrqXtrgdCwpodT/vZvRw found at /home/myuser/.ssh/authorized_keys:1
debug1: restore_uid: 0/0
Postponed publickey for myuser from port 43968 ssh2 [preauth]
Received disconnect from port 43968:11: PECL/ssh2 ( [preauth]
 [2020-09-13 20:05 UTC] pierre dot h dot du40 at outlook dot fr
Me too with php 7.3.22 and debian 10.

PHP error is "ssh2_auth_pubkey_file(): Authentication failed for datahosting using public key: Callback returned error" 

My solution is therefore to use a password authentication, but I would like another solution to continue using the key system
 [2021-01-05 13:10 UTC] l dot fuerderer at gmail dot com
I came across this bug report because it seemed as if I had the exact same issue. (Debian 10, PHP 7.3)

But it was just a permission problem of the private key file. Note, that you get the same error message if PHP can't read the private key. Be sure to check your permissions carefully.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Sep 20 03:03:36 2021 UTC