mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 18:04:25 +09:00
Added more logging output for publickey auth.
This commit is contained in:
@@ -929,11 +929,12 @@ int ssh_userauth_autopubkey(SSH_SESSION *session, const char *passphrase) {
|
|||||||
}
|
}
|
||||||
string_free(pubkey);
|
string_free(pubkey);
|
||||||
SAFE_FREE(privkeyfile);
|
SAFE_FREE(privkeyfile);
|
||||||
|
ssh_log(session, SSH_LOG_RARE, "Publickey authentication error");
|
||||||
leave_function();
|
leave_function();
|
||||||
return rc;
|
return rc;
|
||||||
} else {
|
} else {
|
||||||
if (rc != SSH_AUTH_SUCCESS){
|
if (rc != SSH_AUTH_SUCCESS){
|
||||||
ssh_log(session, SSH_LOG_RARE, "Public key refused by server");
|
ssh_log(session, SSH_LOG_RARE, "Publickey refused by server");
|
||||||
string_free(pubkey);
|
string_free(pubkey);
|
||||||
pubkey = NULL;
|
pubkey = NULL;
|
||||||
SAFE_FREE(privkeyfile);
|
SAFE_FREE(privkeyfile);
|
||||||
@@ -943,6 +944,7 @@ int ssh_userauth_autopubkey(SSH_SESSION *session, const char *passphrase) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Public key accepted by server! */
|
/* Public key accepted by server! */
|
||||||
|
ssh_log(session, SSH_LOG_RARE, "Trying to read privatekey %s", privkeyfile);
|
||||||
privkey = privatekey_from_file(session, privkeyfile, type, passphrase);
|
privkey = privatekey_from_file(session, privkeyfile, type, passphrase);
|
||||||
if (privkey == NULL) {
|
if (privkey == NULL) {
|
||||||
ssh_log(session, SSH_LOG_FUNCTIONS,
|
ssh_log(session, SSH_LOG_FUNCTIONS,
|
||||||
|
|||||||
@@ -583,6 +583,8 @@ static int pem_get_password(char *buf, int size, int rwflag, void *userdata) {
|
|||||||
(void) rwflag;
|
(void) rwflag;
|
||||||
|
|
||||||
ZERO_STRUCTP(buf);
|
ZERO_STRUCTP(buf);
|
||||||
|
ssh_log(session, SSH_LOG_RARE,
|
||||||
|
"Trying to call external authentication function");
|
||||||
|
|
||||||
if (session && session->options->auth_function) {
|
if (session && session->options->auth_function) {
|
||||||
if ((*session->options->auth_function)("Passphrase for private key:", buf, size, 0, 0,
|
if ((*session->options->auth_function)("Passphrase for private key:", buf, size, 0, 0,
|
||||||
@@ -624,6 +626,7 @@ ssh_private_key privatekey_from_file(SSH_SESSION *session, const char *filename,
|
|||||||
DSA *dsa = NULL;
|
DSA *dsa = NULL;
|
||||||
RSA *rsa = NULL;
|
RSA *rsa = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
ssh_log(session, SSH_LOG_RARE, "Trying to open %s", filename);
|
||||||
file = fopen(filename,"r");
|
file = fopen(filename,"r");
|
||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
ssh_set_error(session, SSH_REQUEST_DENIED,
|
ssh_set_error(session, SSH_REQUEST_DENIED,
|
||||||
@@ -631,6 +634,9 @@ ssh_private_key privatekey_from_file(SSH_SESSION *session, const char *filename,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ssh_log(session, SSH_LOG_RARE, "Trying to read %s, passphase=%s, authcb=%s",
|
||||||
|
filename, passphrase ? "true" : "false",
|
||||||
|
session->options->auth_function ? "true" : "false");
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TYPE_DSS:
|
case TYPE_DSS:
|
||||||
if (passphrase == NULL) {
|
if (passphrase == NULL) {
|
||||||
@@ -953,20 +959,20 @@ ssh_string try_publickey_from_file(SSH_SESSION *session, struct ssh_keys_struct
|
|||||||
|
|
||||||
/* are them readable ? */
|
/* are them readable ? */
|
||||||
snprintf(public, sizeof(public), pub, home);
|
snprintf(public, sizeof(public), pub, home);
|
||||||
ssh_log(session, SSH_LOG_PACKET, "Trying to open public key %s", public);
|
ssh_log(session, SSH_LOG_PACKET, "Trying to open publickey %s", public);
|
||||||
if (!ssh_file_readaccess_ok(public)) {
|
if (!ssh_file_readaccess_ok(public)) {
|
||||||
ssh_log(session, SSH_LOG_PACKET, "Failed");
|
ssh_log(session, SSH_LOG_PACKET, "Failed to open publickey %s", public);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(private, sizeof(private), priv, home);
|
snprintf(private, sizeof(private), priv, home);
|
||||||
ssh_log(session, SSH_LOG_PACKET, "Trying to open private key %s", private);
|
ssh_log(session, SSH_LOG_PACKET, "Trying to open privatekey %s", private);
|
||||||
if (!ssh_file_readaccess_ok(private)) {
|
if (!ssh_file_readaccess_ok(private)) {
|
||||||
ssh_log(session, SSH_LOG_PACKET, "Failed");
|
ssh_log(session, SSH_LOG_PACKET, "Failed to open privatekey %s", private);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssh_log(session, SSH_LOG_PACKET, "Success reading public and private key");
|
ssh_log(session, SSH_LOG_PACKET, "Success opening public and private key");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We are sure both the private and public key file is readable. We return
|
* We are sure both the private and public key file is readable. We return
|
||||||
|
|||||||
Reference in New Issue
Block a user