Functions | |
int | ssh_connect (SSH_SESSION *session) |
connect to the ssh server | |
void | ssh_disconnect (SSH_SESSION *session) |
Disconnect from a session (client or server). | |
int | ssh_finalize (void) |
Finalize and cleanup all libssh and cryptographic data structures. | |
const char * | ssh_get_disconnect_message (SSH_SESSION *session) |
get the disconnect message from the server | |
socket_t | ssh_get_fd (SSH_SESSION *session) |
In case you'd need the file descriptor of the connection to the server/client. | |
char * | ssh_get_issue_banner (SSH_SESSION *session) |
Get the issue banner from the server. | |
int | ssh_get_openssh_version (SSH_SESSION *session) |
Get the version of the OpenSSH server, if it is not an OpenSSH server then 0 will be returned. | |
int | ssh_get_pubkey_hash (SSH_SESSION *session, unsigned char **hash) |
Allocates a buffer with the MD5 hash of the server public key. | |
int | ssh_get_status (SSH_SESSION *session) |
Get session status. | |
int | ssh_get_version (SSH_SESSION *session) |
Get the protocol version of the session. | |
int | ssh_handle_packets (SSH_SESSION *session) |
int | ssh_init (void) |
initialize global cryptographic data structures. | |
int | ssh_is_server_known (SSH_SESSION *session) |
Check if the server is known. | |
SSH_SESSION * | ssh_new (void) |
creates a new ssh session | |
int | ssh_select (CHANNEL **channels, CHANNEL **outchannels, socket_t maxfd, fd_set *readfds, struct timeval *timeout) |
A wrapper for the select syscall. | |
void | ssh_set_blocking (SSH_SESSION *session, int blocking) |
set the session in blocking/nonblocking mode | |
void | ssh_set_fd_except (SSH_SESSION *session) |
say the session it has an exception to catch on the file descriptor | |
void | ssh_set_fd_toread (SSH_SESSION *session) |
say to the session it has data to read on the file descriptor without blocking | |
void | ssh_set_fd_towrite (SSH_SESSION *session) |
say the session it may write to the file descriptor without blocking | |
void | ssh_set_options (SSH_SESSION *session, SSH_OPTIONS *options) |
set the options for the current session | |
void | ssh_silent_disconnect (SSH_SESSION *session) |
disconnect impolitely from remote host | |
int | ssh_write_knownhost (SSH_SESSION *session) |
You generaly use it when ssh_is_server_known() answered SSH_SERVER_NOT_KNOWN. |
int ssh_connect | ( | SSH_SESSION * | session | ) |
connect to the ssh server
session | ssh session |
References ssh_init(), ssh_log(), and SSH_LOG_RARE.
void ssh_disconnect | ( | SSH_SESSION * | session | ) |
Disconnect from a session (client or server).
session | The SSH session to disconnect. |
References string_free(), and string_from_char().
Referenced by ssh_silent_disconnect().
int ssh_finalize | ( | void | ) |
Finalize and cleanup all libssh and cryptographic data structures.
This function should only be called once, at the end of the program!
0 otherwise
const char* ssh_get_disconnect_message | ( | SSH_SESSION * | session | ) |
get the disconnect message from the server
session | ssh session |
socket_t ssh_get_fd | ( | SSH_SESSION * | session | ) |
In case you'd need the file descriptor of the connection to the server/client.
recover the fd of connection
session | ssh session |
char* ssh_get_issue_banner | ( | SSH_SESSION * | session | ) |
Get the issue banner from the server.
This is the banner showing a disclaimer to users who log in, typically their right or the fact that they will be monitored.
session | The SSH session to use. |
References string_to_char().
int ssh_get_openssh_version | ( | SSH_SESSION * | session | ) |
Get the version of the OpenSSH server, if it is not an OpenSSH server then 0 will be returned.
You can use the SSH_VERSION_INT macro to compare version numbers.
session | The SSH session to use. |
int ssh_get_pubkey_hash | ( | SSH_SESSION * | session, | |
unsigned char ** | hash | |||
) |
Allocates a buffer with the MD5 hash of the server public key.
session | The SSH session to use. | |
hash | The buffer to allocate. |
ssh_get_hexa()
ssh_print_hexa()
References string_len().
int ssh_get_status | ( | SSH_SESSION * | session | ) |
Get session status.
session | The ssh session to use. |
int ssh_get_version | ( | SSH_SESSION * | session | ) |
Get the protocol version of the session.
session | The ssh session to use. |
int ssh_handle_packets | ( | SSH_SESSION * | session | ) |
int ssh_init | ( | void | ) |
initialize global cryptographic data structures.
This function should only be called once, at the begining of the program, in the main thread. It may be omitted if your program is not multithreaded.
Referenced by ssh_bind_listen(), and ssh_connect().
int ssh_is_server_known | ( | SSH_SESSION * | session | ) |
Check if the server is known.
Checks the user's known host file for a previous connection to the current server.
session | ssh session |
SSH_SESSION* ssh_new | ( | void | ) |
creates a new ssh session
References buffer_new().
Referenced by ssh_bind_accept().
int ssh_select | ( | CHANNEL ** | channels, | |
CHANNEL ** | outchannels, | |||
socket_t | maxfd, | |||
fd_set * | readfds, | |||
struct timeval * | timeout | |||
) |
A wrapper for the select syscall.
This functions acts more or less like the select(2) syscall.
There is no support for writing or exceptions.
channels | Arrays of channels pointers terminated by a NULL. It is never rewritten. | |
outchannels | Arrays of same size that "channels", there is no need to initialize it. | |
maxfd | Maximum +1 file descriptor from readfds. | |
readfds | A fd_set of file descriptors to be select'ed for reading. | |
timeout | A timeout for the select. |
References channel_poll().
void ssh_set_blocking | ( | SSH_SESSION * | session, | |
int | blocking | |||
) |
set the session in blocking/nonblocking mode
session | ssh session | |
blocking | zero for nonblocking mode |
void ssh_set_fd_except | ( | SSH_SESSION * | session | ) |
say the session it has an exception to catch on the file descriptor
session | ssh session |
void ssh_set_fd_toread | ( | SSH_SESSION * | session | ) |
say to the session it has data to read on the file descriptor without blocking
session | ssh session |
void ssh_set_fd_towrite | ( | SSH_SESSION * | session | ) |
say the session it may write to the file descriptor without blocking
session | ssh session |
void ssh_set_options | ( | SSH_SESSION * | session, | |
SSH_OPTIONS * | options | |||
) |
set the options for the current session
session | ssh session | |
options | options structure |
void ssh_silent_disconnect | ( | SSH_SESSION * | session | ) |
disconnect impolitely from remote host
session | current ssh session |
References ssh_disconnect().
int ssh_write_knownhost | ( | SSH_SESSION * | session | ) |
You generaly use it when ssh_is_server_known() answered SSH_SERVER_NOT_KNOWN.
write the current server as known in the known hosts file. This will create the known hosts file if it does not exist.
session | ssh session |
References ssh_dirname(), ssh_mkdir(), and string_len().