ssh.auth

Description

Authenticate an SSH connection.

Syntax

boolean = ssh.auth(sshconn, username, password | { pass, prv, pub })

ParameterDescription
sshconn An active ssh-conn connection.
username String containing the account username to connect as.
password String containing the account password.
pass String containing the passphrase of the private key (used with key-based authentication).
prv String containing the location of the private key (used with key-based authentication).
pub String containing the location of the public key (used with key-based authentication).

Return Value

Returns true if successful. Any failure to authenticate returns false.

Remarks

None

Example

The following example demonstrates how to authenticate via user/pass or a keypair.

global username = "user";
global password = "pass";
global rsa_keys = {
	pass="rsapass",
	prv="~/.ssh/id_rsa",
	pub="~/.ssh/id_rsa.pub"
};

/* you can authenticate with a user/pass pair */
if (ssh.auth(conn, username, password)!=true) {
	print("failed auth");
	exit;
}
/* or you can authenticate with keys */
if (ssh.auth(conn, username, rsa_keys)!=true) {
	print("failed auth");
	exit;
}