|
int | ssh_getpass (const char *prompt, char *buf, size_t len, int echo, int verify) |
| Get a password from the console. More...
|
|
char * | ssh_get_user_home_dir (void) |
|
int | ssh_file_readaccess_ok (const char *file) |
|
char * | ssh_get_local_username (void) |
|
int | ssh_is_ipaddr_v4 (const char *str) |
|
int | ssh_is_ipaddr (const char *str) |
|
char * | ssh_lowercase (const char *str) |
|
char * | ssh_hostport (const char *host, int port) |
|
char * | ssh_get_hexa (const unsigned char *what, size_t len) |
| Convert a buffer into a colon separated hex string. The caller has to free the memory. More...
|
|
void | ssh_print_hexa (const char *descr, const unsigned char *what, size_t len) |
|
const char * | ssh_version (int req_version) |
| Check if libssh is the required version or get the version string. More...
|
|
struct ssh_list * | ssh_list_new (void) |
|
void | ssh_list_free (struct ssh_list *list) |
|
struct ssh_iterator * | ssh_list_get_iterator (const struct ssh_list *list) |
|
struct ssh_iterator * | ssh_list_find (const struct ssh_list *list, void *value) |
|
size_t | ssh_list_count (const struct ssh_list *list) |
| Get the number of elements in the list. More...
|
|
int | ssh_list_append (struct ssh_list *list, const void *data) |
|
int | ssh_list_prepend (struct ssh_list *list, const void *data) |
|
void | ssh_list_remove (struct ssh_list *list, struct ssh_iterator *iterator) |
|
const void * | _ssh_list_pop_head (struct ssh_list *list) |
|
char * | ssh_dirname (const char *path) |
| Parse directory component. More...
|
|
char * | ssh_basename (const char *path) |
| basename - parse filename component. More...
|
|
int | ssh_mkdir (const char *pathname, mode_t mode) |
| Attempts to create a directory with the given pathname. More...
|
|
char * | ssh_path_expand_tilde (const char *d) |
| Expand a directory starting with a tilde '~'. More...
|
|
char * | ssh_path_expand_escape (ssh_session session, const char *s) |
|
int | ssh_analyze_banner (ssh_session session, int server) |
|
void | ssh_timestamp_init (struct ssh_timestamp *ts) |
|
int | ssh_make_milliseconds (long sec, long usec) |
|
int | ssh_timeout_elapsed (struct ssh_timestamp *ts, int timeout) |
|
int | ssh_timeout_update (struct ssh_timestamp *ts, int timeout) |
| updates a timeout value so it reflects the remaining time More...
|
|
int | ssh_match_group (const char *group, const char *object) |
|
void | explicit_bzero (void *s, size_t n) |
|
char * | strndup (const char *s, size_t n) |
|
void | uint64_inc (unsigned char *counter) |
|
Different helper functions used in the SSH Library.
int ssh_getpass |
( |
const char * |
prompt, |
|
|
char * |
buf, |
|
|
size_t |
len, |
|
|
int |
echo, |
|
|
int |
verify |
|
) |
| |
Get a password from the console.
You should make sure that the buffer is an empty string!
You can also use this function to ask for a username. Then you can fill the buffer with the username and it is shows to the users. If the users just presses enter the buffer will be untouched.
char username[128];
snprintf(username, sizeof(username), "john");
ssh_getpass(
"Username:", username,
sizeof(username), 1, 0);
The prompt will look like this:
Username: [john]
If you press enter then john is used as the username, or you can type it in to change it.
- Parameters
-
[in] | prompt | The prompt to show to ask for the password. |
[out] | buf | The buffer the password should be stored. It NEEDS to be empty or filled out. |
[in] | len | The length of the buffer. |
[in] | echo | Should we echo what you type. |
[in] | verify | Should we ask for the password twice. |
- Returns
- 0 on success, -1 on error.