You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* authenticate client */staticvoidauth_or_disconnect(ssh_sessionssh, ssh_keyprivkey, SEXPrpass, constchar*user){
if(ssh_userauth_none(ssh, NULL) ==SSH_AUTH_SUCCESS)
return;
intmethod=ssh_userauth_list(ssh, NULL);
if (method&SSH_AUTH_METHOD_PUBLICKEY){
if(privkey!=NULL&&ssh_userauth_publickey(ssh, NULL, privkey) ==SSH_AUTH_SUCCESS)
return;
// ssh_userauth_publickey_auto() tries both ssh-agent and standard keys in ~/.ssh// it also automatically picks up SSH_ASKPASS env var set by 'askpass' packageif(privkey==NULL&&ssh_userauth_publickey_auto(ssh, NULL, NULL) ==SSH_AUTH_SUCCESS)
return;
}
if (method&SSH_AUTH_METHOD_INTERACTIVE&&auth_interactive(ssh, rpass, user) ==SSH_AUTH_SUCCESS)
return;
if (method&SSH_AUTH_METHOD_PASSWORD&&auth_password(ssh, rpass, user) ==SSH_AUTH_SUCCESS)
return;
ssh_disconnect(ssh);
Rf_errorcall(R_NilValue, "Authentication with ssh server failed");
}
To have a retry loop, it works on second attempt. Not sure if this is a timeout issue or not waiting for a socket response.
/* authenticate client */staticvoidauth_or_disconnect(ssh_sessionssh, ssh_keyprivkey, SEXPrpass, constchar*user){
if(ssh_userauth_none(ssh, NULL) ==SSH_AUTH_SUCCESS)
return;
intmethod=ssh_userauth_list(ssh, NULL);
if (method&SSH_AUTH_METHOD_PUBLICKEY){
if(privkey!=NULL&&ssh_userauth_publickey(ssh, NULL, privkey) ==SSH_AUTH_SUCCESS)
return;
// ssh_userauth_publickey_auto() tries both ssh-agent and standard keys in ~/.ssh// it also automatically picks up SSH_ASKPASS env var set by 'askpass' packageif(privkey==NULL&&ssh_userauth_publickey_auto(ssh, NULL, NULL) ==SSH_AUTH_SUCCESS)
return;
}
if (method&SSH_AUTH_METHOD_INTERACTIVE&&auth_interactive(ssh, rpass, user) ==SSH_AUTH_SUCCESS)
return;
// CHANGE START+++++++++++++++++++++++++++++++++++++if (method&SSH_AUTH_METHOD_PASSWORD) {
inttries;
intrc;
rc=SSH_AUTH_AGAIN;
while (rc!=SSH_AUTH_SUCCESS) {
tries+=1;
REprintf("\nTrying password...via auth_password...attempt %i\n", tries);
rc=auth_password(ssh, rpass, user);
REprintf(" rc = %i\n", rc);
if (rc==SSH_AUTH_SUCCESS) {
return;
}
if (tries>5) {
break;
}
}
}
// CHANGE END+++++++++++++++++++++++++++++++++++++ssh_disconnect(ssh);
Rf_errorcall(R_NilValue, "Authentication with ssh server failed");
}
Example output from my tweaked code:
ssh_userauth_publickey_auto: Private key /home/bschulth/.ssh/identity doesn't exist.ssh_userauth_publickey_auto: Tried every public key, none matchedTrying password...via auth_password...attempt 1ssh_socket_unbuffered_write: Enabling POLLOUT for socketpacket_send2: packet: wrote [len=76,padding=19,comp=56,payload=56]ssh_socket_pollcallback: Poll callback on socket 29 (POLLOUT ), out buffer 0ssh_socket_pollcallback: sending control flow eventssh_packet_socket_controlflow_callback: sending channel_write_wontblock callback rc = 1Trying password...via auth_password...attempt 2ssh_socket_pollcallback: Poll callback on socket 29 (POLLIN ), out buffer 0ssh_packet_socket_callback: packet: read type 52 [len=12,padding=10,comp=1,payload=1]ssh_packet_process: Dispatching handler for packet type 52ssh_packet_userauth_success: Authentication successfulssh_packet_userauth_success: Received SSH_USERAUTH_SUCCESS rc = 0
The text was updated successfully, but these errors were encountered:
SSH_AUTH_METHOD_PASSWORD
...it fails to authenticate in this block of code:The text was updated successfully, but these errors were encountered: