Authentication functions

functions to authenticate to servers More...

Functions

void private_key_free (PRIVATE_KEY *prv)
 deallocate a private key
PRIVATE_KEY * privatekey_from_file (SSH_SESSION *session, char *filename, int type, char *passphrase)
 Reads a SSH private key from a file.
STRING * publickey_from_file (SSH_SESSION *session, char *filename, int *_type)
 Retrieve a public key from a file.
PUBLIC_KEY * publickey_from_privatekey (PRIVATE_KEY *prv)
 Makes a PUBLIC_KEY object out of a PRIVATE_KEY object.
STRING * publickey_to_string (PUBLIC_KEY *key)
 makes a SSH String out of a PUBLIC_KEY object
int ssh_userauth_autopubkey (SSH_SESSION *session)
 Tries to automaticaly authenticate with public key and "none".
int ssh_userauth_kbdint (SSH_SESSION *session, const char *user, const char *submethods)
 Try to authenticate through the "keyboard-interactive" method.
char * ssh_userauth_kbdint_getinstruction (SSH_SESSION *session)
 get the "instruction" of the message block
char * ssh_userauth_kbdint_getname (SSH_SESSION *session)
 get the "name" of the message block
int ssh_userauth_kbdint_getnprompts (SSH_SESSION *session)
 get the number of prompts (questions) the server has given
char * ssh_userauth_kbdint_getprompt (SSH_SESSION *session, int i, char *echo)
 get a prompt from a message block
void ssh_userauth_kbdint_setanswer (SSH_SESSION *session, unsigned int i, const char *answer)
 set the answer for a question from a message block.
int ssh_userauth_none (SSH_SESSION *session, const char *username)
 Try to authenticate through the "none" method.
int ssh_userauth_offer_pubkey (SSH_SESSION *session, const char *username, int type, STRING *publickey)
 Try to authenticate through public key.
int ssh_userauth_password (SSH_SESSION *session, const char *username, const char *password)
 Try to authenticate by password.
int ssh_userauth_pubkey (SSH_SESSION *session, const char *username, STRING *publickey, PRIVATE_KEY *privatekey)
 Try to authenticate through public key.

Detailed Description

functions to authenticate to servers


Function Documentation

void private_key_free ( PRIVATE_KEY *  prv  ) 

deallocate a private key

Parameters:
prv a PRIVATE_KEY object

PRIVATE_KEY* privatekey_from_file ( SSH_SESSION *  session,
char *  filename,
int  type,
char *  passphrase 
)

Reads a SSH private key from a file.

Parameters:
session SSH Session
filename Filename containing the private key
type Type of the private key. One of TYPE_DSS or TYPE_RSA.
passphrase Passphrase to decrypt the private key. Set to null if none is needed or it is unknown.
Returns:
a PRIVATE_KEY object containing the private key, or NULL if it failed.
See also:
private_key_free()

publickey_from_privatekey()

STRING* publickey_from_file ( SSH_SESSION *  session,
char *  filename,
int *  _type 
)

Retrieve a public key from a file.

Parameters:
session the SSH session
filename Filename of the key
_type Pointer to a integer. If it is not null, it contains the type of the key after execution.
Returns:
a SSH String containing the public key, or NULL if it failed.
See also:
string_free()

publickey_from_privatekey()

PUBLIC_KEY* publickey_from_privatekey ( PRIVATE_KEY *  prv  ) 

Makes a PUBLIC_KEY object out of a PRIVATE_KEY object.

Parameters:
prv the Private key
Returns:
the public key
See also:
publickey_to_string()

STRING* publickey_to_string ( PUBLIC_KEY *  key  ) 

makes a SSH String out of a PUBLIC_KEY object

Parameters:
key the public key
Returns:
a SSH String containing the public key
See also:
string_free()

int ssh_userauth_autopubkey ( SSH_SESSION *  session  ) 

Tries to automaticaly authenticate with public key and "none".

it may fail, for instance it doesn't ask for a password and uses a default asker for passphrases (in case the private key is encrypted)

Parameters:
session ssh session
Returns:
SSH_AUTH_ERROR : a serious error happened
SSH_AUTH_DENIED : Authentication failed : use another method
SSH_AUTH_PARTIAL : You've been partially authenticated, you still have to use another method
SSH_AUTH_SUCCESS : Authentication success
See also:
ssh_userauth_kbdint()

ssh_userauth_password()

ssh_options_set_identity()

int ssh_userauth_kbdint ( SSH_SESSION *  session,
const char *  user,
const char *  submethods 
)

Try to authenticate through the "keyboard-interactive" method.

Parameters:
session ssh session
user username to authenticate. You can specify NULL if ssh_option_set_username() has been used. You cannot try two different logins in a row.
submethods undocumented. Set it to NULL
Returns:
SSH_AUTH_ERROR : a serious error happened
SSH_AUTH_DENIED : Authentication failed : use another method
SSH_AUTH_PARTIAL : You've been partially authenticated, you still have to use another method
SSH_AUTH_SUCCESS : Authentication success
SSH_AUTH_INFO : The server asked some questions. Use ssh_userauth_kbdint_getnprompts() and such.
See also:
ssh_userauth_kbdint_getnprompts()

ssh_userauth_kbdint_getname()

ssh_userauth_kbdint_getinstruction()

ssh_userauth_kbdint_getprompt()

ssh_userauth_kbdint_setanswer()

char* ssh_userauth_kbdint_getinstruction ( SSH_SESSION *  session  ) 

get the "instruction" of the message block

You have called ssh_userauth_kbdint() and got SSH_AUTH_INFO. this function returns the questions from the server

Parameters:
session ssh session
Returns:
instruction of the message block

char* ssh_userauth_kbdint_getname ( SSH_SESSION *  session  ) 

get the "name" of the message block

You have called ssh_userauth_kbdint() and got SSH_AUTH_INFO. this function returns the questions from the server

Parameters:
session ssh session
Returns:
name of the message block. Do not free it

int ssh_userauth_kbdint_getnprompts ( SSH_SESSION *  session  ) 

get the number of prompts (questions) the server has given

You have called ssh_userauth_kbdint() and got SSH_AUTH_INFO. this function returns the questions from the server

Parameters:
session ssh session
Returns:
number of prompts

char* ssh_userauth_kbdint_getprompt ( SSH_SESSION *  session,
int  i,
char *  echo 
)

get a prompt from a message block

You have called ssh_userauth_kbdint() and got SSH_AUTH_INFO. this function returns the questions from the server

Parameters:
session ssh session
i index number of the ith prompt
echo when different of NULL, it will obtain a boolean meaning that the resulting user input should be echoed or not (like passwords)
Returns:
pointer to the prompt. Do not free it

void ssh_userauth_kbdint_setanswer ( SSH_SESSION *  session,
unsigned int  i,
const char *  answer 
)

set the answer for a question from a message block.

You have called ssh_userauth_kbdint() and got SSH_AUTH_INFO. this function returns the questions from the server

Parameters:
session ssh session
i index number of the ith prompt
answer answer to give to server

int ssh_userauth_none ( SSH_SESSION *  session,
const char *  username 
)

Try to authenticate through the "none" method.

Parameters:
session ssh session
username username to authenticate. You can specify NULL if ssh_option_set_username() has been used. You cannot try two different logins in a row.
Returns:
SSH_AUTH_ERROR : a serious error happened
SSH_AUTH_DENIED : Authentication failed : use another method
SSH_AUTH_PARTIAL : You've been partially authenticated, you still have to use another method
SSH_AUTH_SUCCESS : Authentication success

int ssh_userauth_offer_pubkey ( SSH_SESSION *  session,
const char *  username,
int  type,
STRING *  publickey 
)

Try to authenticate through public key.

Parameters:
session ssh session
username username to authenticate. You can specify NULL if ssh_option_set_username() has been used. You cannot try two different logins in a row.
type type of public key. This value is given by publickey_from_file()
publickey a public key returned by publickey_from_file()
Returns:
SSH_AUTH_ERROR : a serious error happened
SSH_AUTH_DENIED : The server doesn't accept that public key as an authentication token. Try another key or another method
SSH_AUTH_PARTIAL : You've been partially authenticated, you still have to use another method
SSH_AUTH_SUCCESS : The public key is accepted, you want now to use ssh_userauth_pubkey()
See also:
publickey_from_file()

privatekey_from_file()

ssh_userauth_pubkey()

int ssh_userauth_password ( SSH_SESSION *  session,
const char *  username,
const char *  password 
)

Try to authenticate by password.

Parameters:
session ssh session
username username to authenticate. You can specify NULL if ssh_option_set_username() has been used. You cannot try two different logins in a row.
password password to use. Take care to clean it after authentication
Returns:
SSH_AUTH_ERROR : a serious error happened
SSH_AUTH_DENIED : Authentication failed : use another method
SSH_AUTH_PARTIAL : You've been partially authenticated, you still have to use another method
SSH_AUTH_SUCCESS : Authentication success
See also:
ssh_userauth_kbdint()

int ssh_userauth_pubkey ( SSH_SESSION *  session,
const char *  username,
STRING *  publickey,
PRIVATE_KEY *  privatekey 
)

Try to authenticate through public key.

Parameters:
session ssh session
username username to authenticate. You can specify NULL if ssh_option_set_username() has been used. You cannot try two different logins in a row.
publickey a public key returned by publickey_from_file()
privatekey a private key returned by privatekey_from_file()
Returns:
SSH_AUTH_ERROR : a serious error happened
SSH_AUTH_DENIED : Authentication failed : use another method
SSH_AUTH_PARTIAL : You've been partially authenticated, you still have to use another method
SSH_AUTH_SUCCESS : Authentication success
See also:
publickey_from_file()

privatekey_from_file()

private_key_free()

ssh_userauth_offer_pubkey()


Generated on Sun Aug 23 08:55:36 2009 for libssh by  doxygen 1.4.7