I'm trying to log into an SSH server using a ECDSA client certificate in PHP. I'm using the master dev branch of phpseclib which includes support for ECDSA since October 2018.
I've taken the sample script for logging into an ssh server, and adapted it to use my certificate:
use phpseclib\Crypt\ECDSA;
use phpseclib\Net\SFTP;
$sftp = new SFTP('server.ssh');
$key = new ECDSA();
echo $key->load(file_get_contents('/path/to/clientkey'));
if (!$sftp->login('username', $key)) {
print_r($sftp->getErrors());
echo 'Login Failed';
} else {
echo 'Login Succeeded!';
}
This code yields the following pretty much instantaneously (so no timeout):
1 // so the key loads successfully
Array
(
) // no errors that we know of
Login Failed // but no success either
The same login data works using sftp command line on the same machine. The remote server only supports SFTP connections, so I can't try a regular SSH2 connection.
Is this supposed to work yet? Is this how it's supposed to work, or is there an error in my code?