1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Add binding for libssh2_userauth_publickey_frommemory

This commit is contained in:
dmiller
2024-10-03 19:18:13 +00:00
parent f8b7e5c860
commit 79b35dcb04
2 changed files with 78 additions and 27 deletions

View File

@@ -95,10 +95,10 @@ function SSHConnection:password_auth (username, password)
end
---
-- Attempts to authenticate using provided private key.
-- Attempts to authenticate using provided private key file.
--
-- @param username A username to authenticate as.
-- @param privatekey_file A path to a privatekey.
-- @param privatekey_file A path to a privatekey file.
-- @param passphrase A passphrase for the privatekey.
-- @return true on success or false on failure.
function SSHConnection:publickey_auth (username, privatekey_file, passphrase)
@@ -113,6 +113,25 @@ function SSHConnection:publickey_auth (username, privatekey_file, passphrase)
end
end
---
-- Attempts to authenticate using provided private key.
--
-- @param username A username to authenticate as.
-- @param privatekey The privatekey as a string.
-- @param passphrase A passphrase for the privatekey.
-- @return true on success or false on failure.
function SSHConnection:publickey_auth_frommemory (username, privatekey, passphrase)
if not self.session then
return false
end
if libssh2.userauth_publickey_frommemory(self.session, username, privatekey, passphrase or "") then
self.authenticated = true
return true
else
return false
end
end
---
-- Closes connection.
function SSHConnection:disconnect ()