#include <ne7ssh_connection.h>

Public Member Functions | |
| ne7ssh_connection () | |
| ~ne7ssh_connection () | |
| int | connectWithPassword (uint32 channelID, const char *host, uint32 port, const char *username, const char *password, bool shell=true, int timeout=0) |
| int | connectWithKey (uint32 channelID, const char *host, uint32 port, const char *username, const char *privKeyFileName, bool shell=true, int timeout=0) |
| SOCKET | getSocket () |
| void | handleData () |
| void | sendData (const char *data) |
| void | setChannelNo (int channelID) |
| int | getChannelNo () |
| bool | data2Send () |
| void | sendData () |
| bool | sendCmd (const char *cmd) |
| bool | sendClose () |
| bool | isOpen () |
| bool | isConnected () |
| Botan::SecureVector < Botan::byte > & | getReceived () |
| bool | getCmdComplete () |
| bool | isCmdClosed () |
| bool | isRemoteShell () |
| bool | isCmdRunning () |
| Ne7sshSftp * | startSftp () |
| bool | isSftpActive () |
Private Member Functions | |
| bool | checkRemoteVersion () |
| bool | sendLocalVersion () |
| bool | requestService (const char *service) |
| bool | authWithPassword (const char *username, const char *password) |
| bool | authWithKey (const char *username, const char *privKeyFileName) |
Private Attributes | |
| SOCKET | sock |
| int | thisChannel |
| ne7ssh_crypt * | crypto |
| ne7ssh_transport * | transport |
| ne7ssh_session * | session |
| ne7ssh_channel * | channel |
| Ne7sshSftp * | sftp |
| Ne7ssh_Mutex | mut |
| bool | connected |
| bool | cmdRunning |
| bool | cmdClosed |
| ne7ssh_connection::ne7ssh_connection | ( | ) |
ne7ssh_connection class constructor.
| ne7ssh_connection::~ne7ssh_connection | ( | ) |
ne7ssh_connection class destructor.
| bool ne7ssh_connection::authWithKey | ( | const char * | username, | |
| const char * | privKeyFileName | |||
| ) | [private] |
Sends a test message to check if "publickey" authentication is allowed fo specified user. If succesfull proceeds wtih generating a signature and sending real authentication packet of "publickey" type.
| username | Username used for authentication. | |
| privKeyFileName | Full path to file containing private key to be used in authentication. |
References ne7ssh_string::addChar(), ne7ssh_string::addString(), ne7ssh_string::addVector(), ne7ssh_string::addVectorField(), ne7ssh_string::clear(), ne7ssh::errors(), ne7ssh_keys::generateSignature(), ne7ssh_string::getByte(), ne7ssh_keys::getKeyAlgo(), ne7ssh_keys::getKeyPairFromFile(), ne7ssh_transport::getPacket(), ne7ssh_keys::getPublicKeyBlob(), ne7ssh_session::getSessionID(), ne7ssh_session::getSshChannel(), ne7ssh_string::getString(), Ne7sshError::push(), ne7ssh_transport::sendPacket(), ne7ssh_string::value(), and ne7ssh_transport::waitForPacket().
Referenced by connectWithKey().
| bool ne7ssh_connection::authWithPassword | ( | const char * | username, | |
| const char * | password | |||
| ) | [private] |
Sends an authentication request of "password" type. Waits for packet 'USERAUTH_SUCESS'.
| username | Username used for authentication. | |
| password | Password used for authentication. |
References ne7ssh_string::addChar(), ne7ssh_string::addString(), ne7ssh_string::clear(), ne7ssh::errors(), ne7ssh_string::getByte(), ne7ssh_transport::getPacket(), ne7ssh_string::getString(), Ne7sshError::push(), ne7ssh_transport::sendPacket(), ne7ssh_string::value(), and ne7ssh_transport::waitForPacket().
Referenced by connectWithPassword().
| bool ne7ssh_connection::checkRemoteVersion | ( | ) | [private] |
Checks if remote side is returning a correctly formated SSH version string, and makes sure that version 2 of SSH protocol is supported by the remote side.
References ne7ssh::errors(), ne7ssh_session::getSshChannel(), Ne7sshError::push(), ne7ssh_transport::receive(), and ne7ssh_session::setRemoteVersion().
Referenced by connectWithKey(), and connectWithPassword().
| int ne7ssh_connection::connectWithKey | ( | uint32 | channelID, | |
| const char * | host, | |||
| uint32 | port, | |||
| const char * | username, | |||
| const char * | privKeyFileName, | |||
| bool | shell = true, |
|||
| int | timeout = 0 | |||
| ) |
Connects to a remote host using SSH protocol version 2, with publickey based authentication.
| channelID | ID assigned to the new channel. | |
| host | Hostname / IP of the remote host. | |
| port | Connection port. | |
| username | Username to use in the authentication. | |
| privKeyFileName | Full path to file containing private key to be used in authentication. | |
| shell | Set this to true if you wish to launch the shell on the remote end. By default set to true. | |
| timeout | Timeout for the connection procedure, in seconds. |
References authWithKey(), checkRemoteVersion(), ne7ssh_transport::establish(), ne7ssh_channel::getShell(), ne7ssh_kex::handleInit(), ne7ssh_kex::handleKexDHReply(), ne7ssh_channel::open(), requestService(), ne7ssh_kex::sendInit(), ne7ssh_kex::sendKexDHInit(), ne7ssh_kex::sendKexNewKeys(), sendLocalVersion(), and ne7ssh_session::setSshChannel().
Referenced by ne7ssh::connectWithKey().
| int ne7ssh_connection::connectWithPassword | ( | uint32 | channelID, | |
| const char * | host, | |||
| uint32 | port, | |||
| const char * | username, | |||
| const char * | password, | |||
| bool | shell = true, |
|||
| int | timeout = 0 | |||
| ) |
Connects to a remote host using SSH protocol version 2, with password based authentication.
| channelID | ID of the new channel. | |
| host | Hostname / IP of the remote host. | |
| port | Connection port. | |
| username | Username to use in the authentication. | |
| password | Password to use in the authentication. | |
| shell | Set this to true if you wish to launch the shell on the remote end. By default set to true. | |
| timeout | Timeout for the connection procedure, in seconds. |
References authWithPassword(), checkRemoteVersion(), ne7ssh_transport::establish(), ne7ssh_channel::getShell(), ne7ssh_kex::handleInit(), ne7ssh_kex::handleKexDHReply(), ne7ssh_channel::open(), requestService(), ne7ssh_kex::sendInit(), ne7ssh_kex::sendKexDHInit(), ne7ssh_kex::sendKexNewKeys(), sendLocalVersion(), and ne7ssh_session::setSshChannel().
Referenced by ne7ssh::connectWithPassword().
| bool ne7ssh_connection::data2Send | ( | ) | [inline] |
Checks for the data in the send buffer.
References ne7ssh_channel::data2Send().
| int ne7ssh_connection::getChannelNo | ( | ) | [inline] |
Retrieves the current SSH channel.
| bool ne7ssh_connection::getCmdComplete | ( | ) | [inline] |
When executing a single command with ne7ssh::sendCmd this command is used to determine when remote side finishes the xecution.
References ne7ssh_channel::getCmdComplete().
Referenced by sendClose().
| Botan::SecureVector<Botan::byte>& ne7ssh_connection::getReceived | ( | ) | [inline] |
Retrieves the last received packet.
References ne7ssh_channel::getReceived().
Referenced by ne7ssh::getReceivedSize(), ne7ssh::read(), and ne7ssh::readBinary().
| SOCKET ne7ssh_connection::getSocket | ( | ) | [inline] |
Retrieves the tcp socket number.
| void ne7ssh_connection::handleData | ( | ) |
When new data arrives, and is available for reading, this function is called from selectThread to handle it.
References ne7ssh_channel::receive().
Referenced by ne7ssh::selectThread().
| bool ne7ssh_connection::isCmdClosed | ( | ) | [inline] |
When executing a single command with ne7ssh::sendCmd this command is used to determine when the user requested a close() on the channel.
| bool ne7ssh_connection::isCmdRunning | ( | ) | [inline] |
Checks if current connection is executing a single command, without a shell.
| bool ne7ssh_connection::isConnected | ( | ) | [inline] |
Checks if process is connected and authenticated to the remote side.
| bool ne7ssh_connection::isOpen | ( | ) | [inline] |
Checks if channel is open.
References ne7ssh_channel::isOpen().
| bool ne7ssh_connection::isRemoteShell | ( | ) | [inline] |
Determines if the shell has been spawned on the remote side.
References ne7ssh_channel::isRemoteShell().
| bool ne7ssh_connection::isSftpActive | ( | ) |
Checks if SFTP subsystem is active on the current connection.
Referenced by sendClose().
| bool ne7ssh_connection::requestService | ( | const char * | service | ) | [private] |
Sends an SSH service request, waits for 'SERVICE_ACCEPT' packet.
| service | pointer to a string containing the requested SSH service. For example "ssh-userauth". |
References ne7ssh_string::addChar(), ne7ssh_string::addString(), ne7ssh::errors(), ne7ssh_session::getSshChannel(), Ne7sshError::push(), ne7ssh_transport::sendPacket(), ne7ssh_string::value(), and ne7ssh_transport::waitForPacket().
Referenced by connectWithKey(), and connectWithPassword().
| bool ne7ssh_connection::sendClose | ( | ) |
This function is used to close the current connection.
First closes the channel, and then the connection itself.
References getCmdComplete(), ne7ssh_channel::isOpen(), isSftpActive(), and ne7ssh_channel::sendClose().
Referenced by ne7ssh::close().
| bool ne7ssh_connection::sendCmd | ( | const char * | cmd | ) |
| void ne7ssh_connection::sendData | ( | ) | [inline] |
Sends the content of the buffer.,
Usually used after data2Send returns true, executed by selectThread.
References ne7ssh_channel::sendAll().
| void ne7ssh_connection::sendData | ( | const char * | data | ) |
This function is used to write commands to the buffer, later to be sent to the remote site for execution.
| data | Pointer to a string, containing command to be written to the buffer. |
References ne7ssh_channel::write().
Referenced by ne7ssh::selectThread(), and ne7ssh::send().
| bool ne7ssh_connection::sendLocalVersion | ( | ) | [private] |
Sends local version string.
References ne7ssh_transport::send(), and ne7ssh_session::setLocalVersion().
Referenced by connectWithKey(), and connectWithPassword().
| void ne7ssh_connection::setChannelNo | ( | int | channelID | ) | [inline] |
Sets the current SSH channel number.
Referenced by ne7ssh::connectWithKey(), and ne7ssh::connectWithPassword().
| Ne7sshSftp * ne7ssh_connection::startSftp | ( | ) |
Starts a new sftp subsystem.
References ne7ssh::errors(), ne7ssh_session::getSshChannel(), Ne7sshSftp::init(), ne7ssh_channel::isRemoteShell(), and Ne7sshError::push().
Referenced by ne7ssh::initSftp().
1.5.9