libssh  0.7.3
Public Member Functions
ssh::Session Class Reference

The ssh::Session class contains the state of a SSH connection. More...

#include <include/libssh/libsshpp.hpp>

Public Member Functions

ChannelacceptForward (int timeout_ms)
 accept an incoming forward connection More...
 
void connect ()
 connects to the remote host More...
 
void disconnect ()
 Disconnects from the SSH server and closes connection. More...
 
int getAuthList ()
 Returns the available authentication methods from the server. More...
 
const char * getDisconnectMessage ()
 Returns the disconnect message from the server, if any. More...
 
std::string getIssueBanner ()
 gets the Issue banner from the ssh server More...
 
int getOpensshVersion ()
 returns the OpenSSH version (server) if possible More...
 
socket_t getSocket ()
 returns the file descriptor used for the communication More...
 
int getVersion ()
 returns the version of the SSH protocol being used More...
 
int isServerKnown ()
 verifies that the server is known More...
 
void optionsCopy (const Session &source)
 copies options from a session to another More...
 
void optionsParseConfig (const char *file)
 parses a configuration file for options More...
 
void setOption (enum ssh_options_e type, const char *option)
 sets an SSH session options More...
 
void setOption (enum ssh_options_e type, long int option)
 sets an SSH session options More...
 
void setOption (enum ssh_options_e type, void *option)
 sets an SSH session options More...
 
void silentDisconnect ()
 silently disconnect from remote host More...
 
int userauthNone ()
 Authenticates using the "none" method. More...
 
int userauthPassword (const char *password)
 Authenticates using the password method. More...
 
int userauthPublickey (ssh_key privkey)
 Authenticates using the publickey method. More...
 
int userauthPublickeyAuto (void)
 Authenticates automatically using public key. More...
 
int userauthTryPublickey (ssh_key pubkey)
 Try to authenticate using the publickey method. More...
 
int writeKnownhost ()
 Writes the known host file with current host key. More...
 

Detailed Description

The ssh::Session class contains the state of a SSH connection.

Member Function Documentation

Channel * ssh::Session::acceptForward ( int  timeout_ms)
inline

accept an incoming forward connection

Parameters
[in]timeout_mstimeout for waiting, in ms
Returns
new Channel pointer on the forward connection
NULL in case of error
Warning
you have to delete this pointer after use
See also
ssh_channel_forward_accept
Session::listenForward

References ssh_channel_accept_forward().

void ssh::Session::connect ( )
inline

connects to the remote host

Exceptions
SshExceptionon error
See also
ssh_connect

References ssh_connect().

void ssh::Session::disconnect ( )
inline

Disconnects from the SSH server and closes connection.

See also
ssh_disconnect

References ssh_disconnect().

int ssh::Session::getAuthList ( )
inline

Returns the available authentication methods from the server.

Exceptions
SshExceptionon error
Returns
Bitfield of available methods.
See also
ssh_userauth_list

References ssh_userauth_list().

const char* ssh::Session::getDisconnectMessage ( )
inline

Returns the disconnect message from the server, if any.

Returns
pointer to the message, or NULL. Do not attempt to free the pointer.

References ssh::SshException::getError(), ssh_get_disconnect_message(), ssh_get_error(), and ssh_get_error_code().

std::string ssh::Session::getIssueBanner ( )
inline

gets the Issue banner from the ssh server

Returns
the issue banner. This is generally a MOTD from server
See also
ssh_get_issue_banner

References ssh_get_issue_banner().

int ssh::Session::getOpensshVersion ( )
inline

returns the OpenSSH version (server) if possible

Returns
openssh version code
See also
ssh_get_openssh_version

References ssh_get_openssh_version().

socket_t ssh::Session::getSocket ( )
inline

returns the file descriptor used for the communication

Returns
the file descriptor
Warning
if a proxycommand is used, this function will only return one of the two file descriptors being used
See also
ssh_get_fd

References ssh_get_fd().

int ssh::Session::getVersion ( )
inline

returns the version of the SSH protocol being used

Returns
the SSH protocol version
See also
ssh_get_version

References ssh_get_version().

int ssh::Session::isServerKnown ( )
inline

verifies that the server is known

Exceptions
SshExceptionon error
Returns
Integer value depending on the knowledge of the server key
See also
ssh_is_server_known

References ssh_is_server_known().

void ssh::Session::optionsCopy ( const Session source)
inline

copies options from a session to another

Exceptions
SshExceptionon error
See also
ssh_options_copy

References ssh_options_copy().

void ssh::Session::optionsParseConfig ( const char *  file)
inline

parses a configuration file for options

Exceptions
SshExceptionon error
Parameters
[in]fileconfiguration file name
See also
ssh_options_parse_config

References ssh_options_parse_config().

void ssh::Session::setOption ( enum ssh_options_e  type,
const char *  option 
)
inline

sets an SSH session options

Parameters
typeType of option
optioncstring containing the value of option
Exceptions
SshExceptionon error
See also
ssh_options_set

References ssh_options_set().

void ssh::Session::setOption ( enum ssh_options_e  type,
long int  option 
)
inline

sets an SSH session options

Parameters
typeType of option
optionlong integer containing the value of option
Exceptions
SshExceptionon error
See also
ssh_options_set

References ssh_options_set().

void ssh::Session::setOption ( enum ssh_options_e  type,
void *  option 
)
inline

sets an SSH session options

Parameters
typeType of option
optionvoid pointer containing the value of option
Exceptions
SshExceptionon error
See also
ssh_options_set

References ssh_options_set().

void ssh::Session::silentDisconnect ( )
inline

silently disconnect from remote host

See also
ssh_silent_disconnect

References ssh_silent_disconnect().

int ssh::Session::userauthNone ( )
inline

Authenticates using the "none" method.

Prefer using autopubkey if possible.

Exceptions
SshExceptionon error
Returns
SSH_AUTH_SUCCESS, SSH_AUTH_PARTIAL, SSH_AUTH_DENIED
See also
ssh_userauth_none
Session::userauthAutoPubkey

References ssh_userauth_none().

int ssh::Session::userauthPassword ( const char *  password)
inline

Authenticates using the password method.

Parameters
[in]passwordpassword to use for authentication
Exceptions
SshExceptionon error
Returns
SSH_AUTH_SUCCESS, SSH_AUTH_PARTIAL, SSH_AUTH_DENIED
See also
ssh_userauth_password

References ssh_userauth_password().

int ssh::Session::userauthPublickey ( ssh_key  privkey)
inline

Authenticates using the publickey method.

Parameters
[in]privkeyprivate key to use for authentication
Exceptions
SshExceptionon error
Returns
SSH_AUTH_SUCCESS, SSH_AUTH_PARTIAL, SSH_AUTH_DENIED
See also
ssh_userauth_pubkey

References ssh_userauth_publickey().

int ssh::Session::userauthPublickeyAuto ( void  )
inline

Authenticates automatically using public key.

Exceptions
SshExceptionon error
Returns
SSH_AUTH_SUCCESS, SSH_AUTH_PARTIAL, SSH_AUTH_DENIED
See also
ssh_userauth_autopubkey

References ssh_userauth_publickey_auto().

int ssh::Session::userauthTryPublickey ( ssh_key  pubkey)
inline

Try to authenticate using the publickey method.

Parameters
[in]pubkeypublic key to use for authentication
Exceptions
SshExceptionon error
Returns
SSH_AUTH_SUCCESS if the pubkey is accepted,
SSH_AUTH_DENIED if the pubkey is denied
See also
ssh_userauth_try_pubkey

References ssh_userauth_try_publickey().

int ssh::Session::writeKnownhost ( )
inline

Writes the known host file with current host key.

Exceptions
SshExceptionon error
See also
ssh_write_knownhost

References ssh_channel_cancel_forward(), ssh_channel_listen_forward(), and ssh_write_knownhost().


The documentation for this class was generated from the following file: