messeing around with libssh
This commit is contained in:
parent
7acd21695f
commit
5fd1c5b2a5
3 changed files with 42 additions and 0 deletions
|
|
@ -129,6 +129,24 @@ void ARC_Ssh_Create(ARC_Ssh **ssh, char *host, char *user, char *password){
|
|||
*ssh = NULL;
|
||||
}
|
||||
|
||||
//if no password is provided try to connect with a public key
|
||||
if(password == NULL){
|
||||
returnCode = ssh_userauth_publickey_auto((*ssh)->session, NULL, NULL);
|
||||
if(returnCode != SSH_AUTH_SUCCESS){
|
||||
arc_errno = ARC_ERRNO_CONNECTION;
|
||||
ARC_DEBUG_LOG(arc_errno, "ARC_Ssh_Create(ssh), ssh failed to authenticate with password: %s\n", ssh_get_error((*ssh)->session));
|
||||
ssh_disconnect((*ssh)->session);
|
||||
ssh_free((*ssh)->session);
|
||||
free(*ssh);
|
||||
*ssh = NULL;
|
||||
}
|
||||
|
||||
ssh_send_ignore((*ssh)->session, "mpv https://youtu.be/1P5BSm_oFJg --input-ipc-server=/tmp/mpvsocket --no-terminal & disown");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//try connecting with password
|
||||
returnCode = ssh_userauth_password((*ssh)->session, NULL, password);
|
||||
if(returnCode != SSH_AUTH_SUCCESS){
|
||||
arc_errno = ARC_ERRNO_CONNECTION;
|
||||
|
|
@ -201,6 +219,8 @@ void ARC_Ssh_ExecStrInNewSession(ARC_Ssh *ssh, char *command){
|
|||
ARC_DEBUG_LOG(arc_errno, "ARC_Ssh_RunInSession(ssh, sessionFn), ssh failed when executing command with error code: %d\n", returnCode);
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
|
||||
ssh_channel_send_eof(channel);
|
||||
ssh_channel_close(channel);
|
||||
ssh_channel_free(channel);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue