I am trying pass publickey (id_rsa.pub) for sftp_write example in libssh2 library.
const char *pubkey = "/home/username/.ssh/id_rsa.pub";
const char *privkey = NULL;
if(libssh2_userauth_publickey_fromfile(session, username,
pubkey, privkey,
password)) {
fprintf(stderr, "\tAuthentication by public key failed\n");
goto shutdown;
}
I have tried openssh format and standard ssh format keys as below.
I got the below errors for two formats of the
standard ssh format ,Athentication failed --> cannot open the file -16
*---- BEGIN SSH2 PUBLIC KEY ----
AAAAB3NzaC1yc2EAAAADAQABAAABAQCjnPF5vKg7NuUXkGbK0Nh5d3GjLNXHB+VozgVn5Ego
DVSjwezr30YJm8gzGrk5aUAEJKbWSUczVj9vCrn7O54K1/VXOggC1a6pun3+Iqvuv0BINRj3
YuC+c9s803mYPSpzZpNPFf3Uj49lKrroUIdnEz3qo/Z9kFbpWfClJPlb7xjrZaZkSgolbxih
8gZ0w3iAuMR5nwnEGQnHkk751jxOtYopzT4w31gFmFYcq/LRbP4S2xJ0r8wl58J8Mm/U/yZx
EhDARHx/mkqMILofAqFvsFSaaASUuFmB9uUJsgJ69s9FbgXnpGhyGoH0nyVsdM/oqwIXtJji
IvbVBEomnCrX
---- END SSH2 PUBLIC KEY ----*
OPen SSH FOrmat, Athentication failed -->
LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED \
LIBSSH2_ERROR_AUTHENTICATION_FAILED ,-18
*"ssh-rsa" AAAAB3NzaC1yc2EAAAADAQABAAABAQCjnPF5vKg7NuUXkGbK0Nh5d3GjLNXHB+VozgVn5EgoDVSjwezr30YJm8gzGrk5aUAEJKbWSUczVj9vCrn7O54K1/VXOggC1a6pun3+Iqvuv0BINRj3YuC+c9s803mYPSpzZpNPFf3Uj49lKrroUIdnEz3qo/Z9kFbpWfClJPlb7xjrZaZkSgolbxih8gZ0w3iAuMR5nwnEGQnHkk751jxOtYopzT4w31gFmFYcq/LRbP4S2xJ0r8wl58J8Mm/U/yZxEhDARHx/mkqMILofAqFvsFSaaASUuFmB9uUJsgJ69s9FbgXnpGhyGoH0nyVsdM/oqwIXtJjiIvbVBEomnCrX*
Can some one suggest if its the public key format problem.
I am using Bitvise server on windows for testing the libssh2 client publickey authentication.
Thnaks & Regards
Vamsi