[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: server API, I can not get authorization by key


Hello, I'm trying to make a server-client using your library, but
authorizing a public key is not achievable. I do on QT with ++. Can I
specify on the server where the authorization file is located, my project
is of course.
On server:

Getcwd (buf, 2048);
QString pathDir = QString (buf) + "/ hostkey /";

Ssh_bind_options_set (sshbind, SSH_BIND_OPTIONS_DSAKEY, qPrintable (pathDir
+ "ssh_host_dsa_key")));
Ssh_bind_options_set (sshbind, SSH_BIND_OPTIONS_RSAKEY, qPrintable (pathDir
+ "ssh_host_rsa_key")));

In PathDIR = "/ home / olegstiv / project /
build-SSHSERVER-Qt_5_8_0_gcc_64-Debug
/ server / hostkey /"

Client

Session = ssh_new ();

If (session == NULL)
Return -1;

Ssh_options_set (session, SSH_OPTIONS_HOST, "localhost");
Ssh_options_set (session, SSH_OPTIONS_PORT, & port);
Ssh_options_set (session, SSH_OPTIONS_LOG_VERBOSITY, & verbosity);

Rc = ssh_connect (session);

If (ssh_pki_import_pubkey_file (qPrintable ("/home/olegstiv/.ssh/id_rsa.pub"),
& pubkey)! = SSH_AUTH_SUCCESS)
{
QDebug () << "all bad guy" << ssh_get_error (session);
}

Int code = ssh_pki_import_privkey_file (qPrintable
("/home/olegstiv/.ssh/id_rsa"), NULL, NULL, NULL, & key);
If (code! = SSH_OK)
{
QDebug () << "Could not read private key!" << code;
Return 0;
}
QDebug () << "asdfasd" << ssh_userauth_try_publickey (session, NULL,
pubkey);
QDebug () << ssh_userauth_publickey (session, NULL, key);
If (rc! = SSH_OK)
{
QDebug () << "ERROR" << ssh_get_error (session);
Ssh_free (session);
Return -1;
}

If (verify_knownhost (session) <0)
{
Ssh_disconnect (session);
Ssh_free (session);
Return -1;
}
Code = ssh_userauth_publickey (session, NULL, key);
If (code! = SSH_AUTH_SUCCESS)
{
QDebug () << "Authorization failed";
Return -1;
}
If (autorization_pubkey (session)! = SSH_AUTH_SUCCESS)
{
Ssh_disconnect (session);
Ssh_free (session);
Return -1;
}

Attachment: Screenshot_20170801_154726.png
Description: PNG image

Attachment: Screenshot_20170801_154734.png
Description: PNG image


Follow-Ups:
Re: Fwd: server API, I can not get authorization by keyAndreas Schneider <asn@xxxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org