2

libssh2_userauth_publickey_fromfile() fails with error code

-19 (LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED).

I want to use Public key authentication method only (and not password based authentication). Authentication by password works fine.

System: Windows Server 2019

API call:

libssh2_userauth_publickey_fromfile(session, username, keyfile1, keyfile2, password)

I have defined keyfile1 and keyfile2 in my C file as:

const char *keyfile1 = "C:\\Users\\Administrator\\.ssh\\id_rsa.pub";
const char *keyfile2 = "C:\\Users\\Administrator\\.ssh\\id_rsa";

I suspect that it has to do something with EOL with the key files on Windows (This call works pretty well on my Linux system (with appropriate key file locations)).

Any idea on how could we remove EOL or extra spaces from the key files so that the libssh2 API call succeeds?

jainsha
  • 63
  • 5

1 Answers1

0

Following libssh2/libssh2 issue 68, check first the version of libssh2 used.

For old version, try with a key following the old PEM format

ssh-keygen -m PEM -t rsa -P "" -f afile 
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250