assh/helper_client.h header reference
Description [link]
This header file provides helper functions designed to ease development of simple ssh2 client applications.
Implementation of client applications may want to reuse and adapt code from this module, as allowed by the license exception covering the source code of this module.
Members [link]
Types [link]
Functions [link]
- assh_status_t asshh_client_add_known_hosts(struct assh_context_s *c, const char *filename, const char *host, const struct assh_key_s *key)
- void asshh_client_event_auth(struct assh_session_s *s, FILE *out, FILE *in, const char *user, const char *host, enum assh_userauth_methods_e *methods, const struct asshh_client_user_key_s *key_files, struct assh_event_s *event)
- void asshh_client_event_hk_add(struct assh_session_s *s, const char *host, struct assh_event_s *event)
- void asshh_client_event_hk_lookup(struct assh_session_s *s, FILE *out, FILE *in, const char *host, struct assh_event_s *event)
- void asshh_client_event_hk_lookup_va(struct assh_session_s *s, FILE *out, FILE *in, const char *host, struct assh_event_s *event, ...)
- void asshh_client_event_inter_session(struct assh_session_s *s, struct assh_event_s *event, struct asshh_client_inter_session_s *state)
- assh_status_t asshh_client_get_known_hosts(struct assh_context_s *c, struct assh_key_s **keys, const char *filename, const char *host)
- void asshh_client_init_inter_session(struct asshh_client_inter_session_s *state, const char *command, const char *term)
Constant [link]
- const struct asshh_client_user_key_s asshh_client_user_key_default[]
Members detail [link]
assh_status_t asshh_client_add_known_hosts(struct assh_context_s *c, const char *filename, const char *host, const struct assh_key_s *key) [link]
This function is declared in assh/helper_client.h source file, line 75.
Preprocessor condition: defined( CONFIG_ASSH_CLIENT )
This function adds a public key at the end of the ssh_knwon_host file.
void asshh_client_event_auth(struct assh_session_s *s, FILE *out, FILE *in, const char *user, const char *host, enum assh_userauth_methods_e *methods, const struct asshh_client_user_key_s *key_files, struct assh_event_s *event) [link]
This function is declared in assh/helper_client.h source file, line 162.
Preprocessor condition: defined( CONFIG_ASSH_CLIENT )
This function implements a default user authentication events handler which interacts with the user on the UNIX terminal and fetches keys in openssh standard locations.
This function is designed to handle the following events:
The authentication methods initially specified in methods will be tried, provided that they are enabled by the server.
The key_files parameter specifies the list of user key files which will be loaded. The user keys are loaded from the user .ssh directory. The asshh_client_user_key_default array can be passed as key_files.
This function takes care of calling the assh_event_done function in any case.
void asshh_client_event_hk_add(struct assh_session_s *s, const char *host, struct assh_event_s *event) [link]
This function is declared in assh/helper_client.h source file, line 114.
Preprocessor condition: defined( CONFIG_ASSH_CLIENT )
This handles the ASSH_EVENT_KEX_DONE event by adding the host key to the openssh known hosts file if needed. This works along with the asshh_client_event_hk_lookup function.
This function takes care of calling the assh_event_done function in any case.
void asshh_client_event_hk_lookup(struct assh_session_s *s, FILE *out, FILE *in, const char *host, struct assh_event_s *event) [link]
This function is declared in assh/helper_client.h source file, line 102.
Preprocessor condition: defined( CONFIG_ASSH_CLIENT )
This function calls the asshh_client_event_hk_lookup_va function with system and user known hosts files.
This function takes care of calling the assh_event_done function in any case.
void asshh_client_event_hk_lookup_va(struct assh_session_s *s, FILE *out, FILE *in, const char *host, struct assh_event_s *event, ...) [link]
This function is declared in assh/helper_client.h source file, line 91.
Preprocessor condition: defined( CONFIG_ASSH_CLIENT )
This function handles the ASSH_EVENT_KEX_HOSTKEY_LOOKUP event by reading some known host files in openssh format. A NULL terminated list of file names is expected.
The user is queried the usual way about key verification and fingerprints. If the standard input is not a tty and user interaction is required, the host key is not accepted.
This function takes care of calling the assh_event_done function in any case.
void asshh_client_event_inter_session(struct assh_session_s *s, struct assh_event_s *event, struct asshh_client_inter_session_s *state) [link]
This function is declared in assh/helper_client.h source file, line 230.
Preprocessor condition: defined( CONFIG_ASSH_CLIENT )
This function implements an events handler which starts an interactive session and requests execution of a command on the remote server.
This function is designed to handle the following events:
This function takes care of calling the assh_event_done function.
assh_status_t asshh_client_get_known_hosts(struct assh_context_s *c, struct assh_key_s **keys, const char *filename, const char *host) [link]
This function is declared in assh/helper_client.h source file, line 68.
Preprocessor condition: defined( CONFIG_ASSH_CLIENT )
This function loads all public keys associated to a given host name and recognized by one of the registered algorithms. The input file must be in openssh ssh_knwon_host file format.
The keys are loaded by the asshh_key_load_file function and must be released by calling assh_key_flush.
A comment string containing the location (file name and line number) is attached to each loaded key.
void asshh_client_init_inter_session(struct asshh_client_inter_session_s *state, const char *command, const char *term) [link]
This function is declared in assh/helper_client.h source file, line 211.
Preprocessor condition: defined( CONFIG_ASSH_CLIENT )
This function initializes an interactive session object for execution of the specified command. This must be used along with the asshh_client_event_inter_session event handler function.
This is a simple helper designed to start a command on a remote server. The associated event handler takes care of sending the appropriate requests to the remote host when the ssh-connection service is started.
When the command parameter is NULL, execution of a shell is requested. When the term parameter is NULL, no pty allocation is requested.
struct asshh_client_inter_session_s [link]
This struct is declared in assh/helper_client.h source file, line 187.
Preprocessor condition: defined( CONFIG_ASSH_CLIENT )
This struct stores the state of the simple interactive session helper between calls to the asshh_client_event_inter_session function.
This struct must be initialized by calling the asshh_client_init_inter_session function.
Field | Description |
---|---|
enum asshh_client_inter_session_state_e state; | |
const char * command; | |
const char * term; | |
uint_fast16_t char_width; | |
uint_fast16_t char_height; | |
struct assh_channel_s * channel; | |
struct assh_request_s * request; |
enum asshh_client_inter_session_state_e [link]
This enum is declared in assh/helper_client.h source file, line 169.
Preprocessor condition: defined( CONFIG_ASSH_CLIENT )
This enum specifies the current state of an interactive session.
See also struct asshh_client_inter_session_s.
Identifier | Description |
---|---|
ASSH_CLIENT_INTER_ST_INIT | |
ASSH_CLIENT_INTER_ST_SESSION | |
ASSH_CLIENT_INTER_ST_PTY | |
ASSH_CLIENT_INTER_ST_EXEC | |
ASSH_CLIENT_INTER_ST_OPEN | |
ASSH_CLIENT_INTER_ST_CLOSING | |
ASSH_CLIENT_INTER_ST_CLOSED |
const struct asshh_client_user_key_s asshh_client_user_key_default[] [link]
This constant is declared in assh/helper_client.h source file, line 131.
Preprocessor condition: defined( CONFIG_ASSH_CLIENT )
This constant contains a default list of user key file for use with the asshh_client_event_auth function.
struct asshh_client_user_key_s [link]
This struct is declared in assh/helper_client.h source file, line 120.
Preprocessor condition: defined( CONFIG_ASSH_CLIENT )
This struct is used to specify the list of user key files for the asshh_client_event_auth function.
See also asshh_client_user_key_default.
Field | Description |
---|---|
const char * filename; | key filename to lookup in the .ssh user directory |
const char * key_algo; | |
enum assh_algo_class_e role; | |
enum assh_key_format_e format; |