SSH auth tries to login with simply password if auth with public key failed

This commit is contained in:
Abdelilah El Aissaoui 2023-04-15 16:03:19 +02:00
parent 2383a3b2db
commit d5aaa1dd30
No known key found for this signature in database
GPG Key ID: 7587FC860F594869
3 changed files with 14 additions and 0 deletions

View File

@ -57,6 +57,10 @@ class GRemoteSession @Inject constructor(
credentials.password
result = session.userAuthPublicKeyAuto(null, password)
if (result != 0) {
result = session.userAuthPassword(password)
}
}
if (result != 0)

View File

@ -33,6 +33,15 @@ class LibSshSession @Inject constructor() {
return result
}
fun userAuthPassword(password: String): Int {
val result = sshLib.ssh_userauth_password(session, null, password)
if (result != 0)
printError(TAG, "Result is: $result.\nError is: ${getError()}")
return result
}
fun createChannel(): LibSshChannel {
val newChannel = LibSshChannel(session)

View File

@ -19,6 +19,7 @@ interface SSHLibrary : Library {
fun ssh_userauth_agent(session: ssh_session, username: String?): Int
fun ssh_userauth_publickey_auto(session: ssh_session, username: String?, password: String?): Int
fun ssh_userauth_password(session: ssh_session, username: String?, password: String?): Int
fun ssh_get_error(session: ssh_session): String
fun ssh_channel_new(sshSession: ssh_session): ssh_channel