class ssh::Session
Overview
The ssh::Session class contains the state of a SSH connection. More…
#include <include/libssh/libsshpp.hpp> class Session { public: // construction ~Session(); // methods Channel* acceptForward(int timeout_ms); void cancelForward( const char* address, int port ); void connect(); void disconnect(); int getAuthList(); const char* getDisconnectMessage(); const char* getError(); int getErrorCode(); std::string getIssueBanner(); int getOpensshVersion(); socket_t getSocket(); int getVersion(); int isServerKnown(); void listenForward( const char* address, int port, int& boundport ); void log( int priority, const char* format, ... ); void optionsCopy(const Session& source); void optionsParseConfig(const char* file); void setOption( enum ssh_options_e type, const char* option ); void setOption( enum ssh_options_e type, long int option ); void setOption( enum ssh_options_e type, void* option ); void silentDisconnect(); int userauthNone(); int userauthPassword(const char* password); int userauthPrivatekeyFile( const char* filename, const char* passphrase ); int userauthPublickey(ssh_key privkey); int userauthPublickeyAuto(void); int userauthTryPublickey(ssh_key pubkey); int writeKnownhost(); };
Detailed Documentation
The ssh::Session class contains the state of a SSH connection.
Methods
Channel* acceptForward(int timeout_ms)
accept an incoming forward connection
Warning
you have to delete this pointer after use
Parameters:
timeout_ms |
timeout for waiting, in ms |
Returns:
new Channel pointer on the forward connection
NULL in case of error
See also:
ssh_channel_forward_accept
void connect()
connects to the remote host
Parameters:
on error |
See also:
void disconnect()
Disconnects from the SSH server and closes connection.
See also:
int getAuthList()
Returns the available authentication methods from the server.
Parameters:
on error |
Returns:
Bitfield of available methods.
See also:
const char* getDisconnectMessage()
Returns the disconnect message from the server, if any.
Returns:
pointer to the message, or NULL. Do not attempt to free the pointer.
std::string getIssueBanner()
gets the Issue banner from the ssh server
Returns:
the issue banner. This is generally a MOTD from server
See also:
int getOpensshVersion()
returns the OpenSSH version (server) if possible
Returns:
openssh version code
See also:
socket_t getSocket()
returns the file descriptor used for the communication
Warning
if a proxycommand is used, this function will only return one of the two file descriptors being used
Returns:
the file descriptor
See also:
int getVersion()
returns the version of the SSH protocol being used
Returns:
the SSH protocol version
See also:
int isServerKnown()
verifies that the server is known
Parameters:
on error |
Returns:
Integer value depending on the knowledge of the server key
See also:
void optionsCopy(const Session& source)
copies options from a session to another
Parameters:
on error |
See also:
void optionsParseConfig(const char* file)
parses a configuration file for options
Parameters:
on error |
|
file |
configuration file name |
See also:
void setOption( enum ssh_options_e type, const char* option )
sets an SSH session options
Parameters:
type |
Type of option |
option |
cstring containing the value of option |
on error |
See also:
void setOption( enum ssh_options_e type, long int option )
sets an SSH session options
Parameters:
type |
Type of option |
option |
long integer containing the value of option |
on error |
See also:
void setOption( enum ssh_options_e type, void* option )
sets an SSH session options
Parameters:
type |
Type of option |
option |
void pointer containing the value of option |
on error |
See also:
void silentDisconnect()
silently disconnect from remote host
See also:
int userauthNone()
Authenticates using the “none” method.
Prefer using autopubkey if possible.
Parameters:
on error |
Returns:
SSH_AUTH_SUCCESS, SSH_AUTH_PARTIAL, SSH_AUTH_DENIED
See also:
Session::userauthAutoPubkey
int userauthPassword(const char* password)
Authenticates using the password method.
Parameters:
password |
password to use for authentication |
on error |
Returns:
SSH_AUTH_SUCCESS, SSH_AUTH_PARTIAL, SSH_AUTH_DENIED
See also:
int userauthPublickey(ssh_key privkey)
Authenticates using the publickey method.
Parameters:
privkey |
private key to use for authentication |
on error |
Returns:
SSH_AUTH_SUCCESS, SSH_AUTH_PARTIAL, SSH_AUTH_DENIED
See also:
int userauthPublickeyAuto(void)
Authenticates automatically using public key.
Parameters:
on error |
Returns:
SSH_AUTH_SUCCESS, SSH_AUTH_PARTIAL, SSH_AUTH_DENIED
See also:
int userauthTryPublickey(ssh_key pubkey)
Try to authenticate using the publickey method.
Parameters:
pubkey |
public key to use for authentication |
on error |
Returns:
SSH_AUTH_SUCCESS if the pubkey is accepted,
SSH_AUTH_DENIED if the pubkey is denied
See also:
ssh_userauth_try_pubkey
int writeKnownhost()
Writes the known host file with current host key.
Parameters:
on error |
See also: