ssh_options

Langue: en

Autres versions - même langue

Version: 319225 (ubuntu - 07/07/09)

Section: 3 (Bibliothèques de fonctions)

NAME

Ssh_options - options settings for a new ssh session

Functions


void ssh_options_allow_ssh1 (SSH_OPTIONS *opt, int allow)
allow or deny the connection to SSH1 servers
void ssh_options_allow_ssh2 (SSH_OPTIONS *opt, int allow)
allow or deny the connection to SSH2 servers
SSH_OPTIONS * ssh_options_copy (SSH_OPTIONS *opt)
copies an option structure
int ssh_options_getopt (SSH_OPTIONS *options, int *argcptr, char **argv)
parse command line arguments
SSH_OPTIONS * ssh_options_new ()
initializes a new option structure
void ssh_options_set_banner (SSH_OPTIONS *opt, char *banner)
set the server banner sent to clients
void ssh_options_set_bind (SSH_OPTIONS *opt, char *bindaddr, int port)
set the local address and port binding
void ssh_options_set_dsa_server_key (SSH_OPTIONS *opt, char *dsakey)

void ssh_options_set_fd (SSH_OPTIONS *opt, int fd)
set a file descriptor for connection
void ssh_options_set_host (SSH_OPTIONS *opt, const char *hostname)
set destination hostname
void ssh_options_set_identity (SSH_OPTIONS *opt, char *identity)
set the identity file name
void ssh_options_set_known_hosts_file (SSH_OPTIONS *opt, char *dir)
set the known hosts file name
void ssh_options_set_port (SSH_OPTIONS *opt, unsigned int port)
set port to connect or to bind for a connection
void ssh_options_set_rsa_server_key (SSH_OPTIONS *opt, char *rsakey)

void ssh_options_set_ssh_dir (SSH_OPTIONS *opt, char *dir)
set the ssh directory
void ssh_options_set_status_callback (SSH_OPTIONS *opt, void(*callback)(void *arg, float status), void *arg)
set a callback to show connection status in realtime
void ssh_options_set_timeout (SSH_OPTIONS *opt, long seconds, long usec)
set a timeout for the connection
void ssh_options_set_username (SSH_OPTIONS *opt, char *username)
set username for authentication
int ssh_options_set_wanted_algos (SSH_OPTIONS *opt, int algo, char *list)
set the algorithms to be used for cryptography and compression

Detailed Description

options settings for a new ssh session

defgroup ssh_options

Function Documentation

void ssh_options_allow_ssh1 (SSH_OPTIONS * opt, int allow)

allow or deny the connection to SSH1 servers

Default value is 0 (no connection to SSH1 servers)

Parameters:

opt options structure
allow nonzero values allow ssh1

void ssh_options_allow_ssh2 (SSH_OPTIONS * opt, int allow)

allow or deny the connection to SSH2 servers

Default value is 1 (allow connection to SSH2 servers)

Parameters:

opt options structure
allow nonzero values allow ssh2

SSH_OPTIONS* ssh_options_copy (SSH_OPTIONS * opt)

copies an option structure

you may need to duplication an option structure if you make several sessions with the same options.

 You cannot use twice the same option structure in ssh_session_connect. 

Parameters:

opt option structure to copy

Returns:

new copied option structure

See also:

ssh_session_connect()

int ssh_options_getopt (SSH_OPTIONS * options, int * argcptr, char ** argv)

parse command line arguments

This is a helper for your application to generate the appropriate options from the command line arguments.

 the argv array and argc value are changed so that parsed arguments won't appear anymore in them.

 The single arguments (without switches) are not parsed. thus, myssh -u aris localhost 

 command won't set the hostname value of options to localhost. 

Parameters:

options an empty option structure pointer
argcptr pointer to argument count
argv arguments list pointer

Returns:

0 on success, -1 on error

See also:

ssh_options_new()

SSH_OPTIONS* ssh_options_new ()

initializes a new option structure

This structure is freed automaticaly by ssh_disconnect() when you use it.

 It can be used by only one ssh_connect(), not more.

 also by default, ssh1 support is not allowed

Returns:

an empty intialized option structure.

See also:

ssh_options_getopt()

void ssh_options_set_banner (SSH_OPTIONS * opt, char * banner)

set the server banner sent to clients

Parameters:

opt options structure
banner a text banner to be shown

void ssh_options_set_bind (SSH_OPTIONS * opt, char * bindaddr, int port)

set the local address and port binding

In case your client has multiple IP adresses, select the local address and port to use for the socket.

 If the address or port is not bindable, it may be impossible to connect. 

Parameters:

opt options structure
bindaddr bind address in form of hostname or ip address
port port number to bind

void ssh_options_set_dsa_server_key (SSH_OPTIONS * opt, char * dsakey)

Warning:

I don't remember what these functions are supposed to set

void ssh_options_set_fd (SSH_OPTIONS * opt, int fd)

set a file descriptor for connection

If you wish to open the socket yourself for a reason or another, set the file descriptor.

 don't forget to use ssh_option_set_hostname() as the hostname is used as a key in the known_host mechanism 

Parameters:

opt options structure
fd an opened file descriptor to use

void ssh_options_set_host (SSH_OPTIONS * opt, const char * hostname)

set destination hostname

Parameters:

opt option structure
hostname host name to connect

void ssh_options_set_identity (SSH_OPTIONS * opt, char * identity)

set the identity file name

the identity file is used authenticate with public key.

Parameters:

opt options structure
identity path to the file including its name. '%s' will be substitued with the user home directory

See also:

ssh_options_set_user_home_dir()

void ssh_options_set_known_hosts_file (SSH_OPTIONS * opt, char * dir)

set the known hosts file name

the known hosts file is used to certify remote hosts are genuine.

Parameters:

opt options structure
dir path to the file including its name. '%s' will be substitued with the user home directory

See also:

ssh_options_set_user_home_dir()

void ssh_options_set_port (SSH_OPTIONS * opt, unsigned int port)

set port to connect or to bind for a connection

Parameters:

opt options structure
port port to connect or to bind

void ssh_options_set_rsa_server_key (SSH_OPTIONS * opt, char * rsakey)

Warning:

I don't remember what these functions are supposed to set

void ssh_options_set_ssh_dir (SSH_OPTIONS * opt, char * dir)

set the ssh directory

the ssh directory is used for files like known_hosts and identity (public and private keys)

 

Parameters:

opt options structure
dir directory. It may include '%s' which will be replaced by the user home directory

See also:

ssh_options_set_user_home_dir()

void ssh_options_set_status_callback (SSH_OPTIONS * opt, void(*)(void *arg, float status) callback, void * arg)

set a callback to show connection status in realtime

During ssh_connect(), libssh will call the callback with status from 0.0 to 1.0

Parameters:

opt options structure
callback a function pointer to a callback in form f(void *userarg, float status)
arg value to be given as argument to the callback function when it is called

See also:

ssh_connect()

void ssh_options_set_timeout (SSH_OPTIONS * opt, long seconds, long usec)

set a timeout for the connection

Bug

currently it only timeouts the socket connection, not the complete exchange

Parameters:

opt options structure
seconds number of seconds
usec number of micro seconds

void ssh_options_set_username (SSH_OPTIONS * opt, char * username)

set username for authentication

Bug

this should not be set at options time

Parameters:

opt options structure
username user name to authenticate

int ssh_options_set_wanted_algos (SSH_OPTIONS * opt, int algo, char * list)

set the algorithms to be used for cryptography and compression

the methods are:

 KEX_HOSTKEY (server public key type) : ssh-rsa or ssh-dss

 KEX_CRYPT_C_S (symmetric cipher client to server)

 KEX_CRYPT_S_C (symmetric cipher server to client)

 KEX_COMP_C_S (Compression client to server): zlib or none

 KEX_COMP_S_C (Compression server to client): zlib or none

 You don't have to use this function if using the default ciphers is okay for you

 in order to enable compression client to server, do

 ret=ssh_options_set_wanted_algos(opt,KEX_COMP_C_S,'zlib'); 

Parameters:

opt options structure
algo method which needs to be changed
list list of algorithms to be used, in order of preference and separated by commas

Returns:

0 on success, -1 on error (most likely an algorithm is not available)