libssh 0.11.1 The SSH library

Loading...
Searching...
No Matches
libssh.h
1/*
2 * This file is part of the SSH Library
3 *
4 * Copyright (c) 2003-2024 by Aris Adamantiadis and the libssh team
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef _LIBSSH_H
22#define _LIBSSH_H
23
24#include <libssh/libssh_version.h>
25
26#if defined _WIN32 || defined __CYGWIN__
27 #ifdef LIBSSH_STATIC
28 #define LIBSSH_API
29 #else
30 #ifdef LIBSSH_EXPORTS
31 #ifdef __GNUC__
32 #define LIBSSH_API __attribute__((dllexport))
33 #else
34 #define LIBSSH_API __declspec(dllexport)
35 #endif
36 #else
37 #ifdef __GNUC__
38 #define LIBSSH_API __attribute__((dllimport))
39 #else
40 #define LIBSSH_API __declspec(dllimport)
41 #endif
42 #endif
43 #endif
44#else
45 #if __GNUC__ >= 4 && !defined(__OS2__)
46 #define LIBSSH_API __attribute__((visibility("default")))
47 #else
48 #define LIBSSH_API
49 #endif
50#endif
51
52#include <stdarg.h>
53#include <stdint.h>
54#include <inttypes.h>
55
56#ifdef _MSC_VER
57 typedef int mode_t;
58#else /* _MSC_VER */
59 #include <unistd.h>
60 #include <sys/types.h>
61#endif /* _MSC_VER */
62
63#ifdef _WIN32
64 #include <winsock2.h>
65#else /* _WIN32 */
66 #include <sys/select.h> /* for fd_set * */
67 #include <netdb.h>
68#endif /* _WIN32 */
69
70#define SSH_STRINGIFY(s) SSH_TOSTRING(s)
71#define SSH_TOSTRING(s) #s
72
73/* GCC have printf type attribute check. */
74#ifdef __GNUC__
75#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
76#else
77#define PRINTF_ATTRIBUTE(a,b)
78#endif /* __GNUC__ */
79
80#if !defined(SSH_SUPPRESS_DEPRECATED) && defined(__GNUC__)
81#define SSH_DEPRECATED __attribute__ ((deprecated))
82#else
83#define SSH_DEPRECATED
84#endif
85
86#ifdef __cplusplus
87 extern "C" {
88#endif
89
90 struct ssh_counter_struct {
91 uint64_t in_bytes;
92 uint64_t out_bytes;
93 uint64_t in_packets;
94 uint64_t out_packets;
95};
96 typedef struct ssh_counter_struct *ssh_counter;
97
98 typedef struct ssh_agent_struct* ssh_agent;
99 typedef struct ssh_buffer_struct* ssh_buffer;
100 typedef struct ssh_channel_struct* ssh_channel;
101 typedef struct ssh_message_struct* ssh_message;
102 typedef struct ssh_pcap_file_struct* ssh_pcap_file;
103 typedef struct ssh_key_struct* ssh_key;
104 typedef struct ssh_scp_struct* ssh_scp;
105 typedef struct ssh_session_struct* ssh_session;
106 typedef struct ssh_string_struct* ssh_string;
107 typedef struct ssh_event_struct* ssh_event;
108 typedef struct ssh_connector_struct * ssh_connector;
109 typedef void* ssh_gssapi_creds;
110
111/* Socket type */
112#ifdef _WIN32
113#ifndef socket_t
114 typedef SOCKET socket_t;
115#endif /* socket_t */
116#else /* _WIN32 */
117#ifndef socket_t
118 typedef int socket_t;
119#endif
120#endif /* _WIN32 */
121
122#define SSH_INVALID_SOCKET ((socket_t) -1)
123
124/* the offsets of methods */
125 enum ssh_kex_types_e {
126 SSH_KEX=0,
127 SSH_HOSTKEYS,
128 SSH_CRYPT_C_S,
129 SSH_CRYPT_S_C,
130 SSH_MAC_C_S,
131 SSH_MAC_S_C,
132 SSH_COMP_C_S,
133 SSH_COMP_S_C,
134 SSH_LANG_C_S,
135 SSH_LANG_S_C
136};
137
138#define SSH_CRYPT 2
139#define SSH_MAC 3
140#define SSH_COMP 4
141#define SSH_LANG 5
142
143 enum ssh_auth_e {
144 SSH_AUTH_SUCCESS=0,
145 SSH_AUTH_DENIED,
146 SSH_AUTH_PARTIAL,
147 SSH_AUTH_INFO,
148 SSH_AUTH_AGAIN,
149 SSH_AUTH_ERROR=-1
150};
151
152/* auth flags */
153#define SSH_AUTH_METHOD_UNKNOWN 0x0000u
154#define SSH_AUTH_METHOD_NONE 0x0001u
155#define SSH_AUTH_METHOD_PASSWORD 0x0002u
156#define SSH_AUTH_METHOD_PUBLICKEY 0x0004u
157#define SSH_AUTH_METHOD_HOSTBASED 0x0008u
158#define SSH_AUTH_METHOD_INTERACTIVE 0x0010u
159#define SSH_AUTH_METHOD_GSSAPI_MIC 0x0020u
160
161/* messages */
162 enum ssh_requests_e {
163 SSH_REQUEST_AUTH=1,
164 SSH_REQUEST_CHANNEL_OPEN,
165 SSH_REQUEST_CHANNEL,
166 SSH_REQUEST_SERVICE,
167 SSH_REQUEST_GLOBAL
168};
169
170 enum ssh_channel_type_e {
171 SSH_CHANNEL_UNKNOWN=0,
172 SSH_CHANNEL_SESSION,
173 SSH_CHANNEL_DIRECT_TCPIP,
174 SSH_CHANNEL_FORWARDED_TCPIP,
175 SSH_CHANNEL_X11,
176 SSH_CHANNEL_AUTH_AGENT
177};
178
179 enum ssh_channel_requests_e {
180 SSH_CHANNEL_REQUEST_UNKNOWN=0,
181 SSH_CHANNEL_REQUEST_PTY,
182 SSH_CHANNEL_REQUEST_EXEC,
183 SSH_CHANNEL_REQUEST_SHELL,
184 SSH_CHANNEL_REQUEST_ENV,
185 SSH_CHANNEL_REQUEST_SUBSYSTEM,
186 SSH_CHANNEL_REQUEST_WINDOW_CHANGE,
187 SSH_CHANNEL_REQUEST_X11
188};
189
190 enum ssh_global_requests_e {
191 SSH_GLOBAL_REQUEST_UNKNOWN=0,
192 SSH_GLOBAL_REQUEST_TCPIP_FORWARD,
193 SSH_GLOBAL_REQUEST_CANCEL_TCPIP_FORWARD,
194 SSH_GLOBAL_REQUEST_KEEPALIVE,
195 SSH_GLOBAL_REQUEST_NO_MORE_SESSIONS
196};
197
198 enum ssh_publickey_state_e {
199 SSH_PUBLICKEY_STATE_ERROR=-1,
200 SSH_PUBLICKEY_STATE_NONE=0,
201 SSH_PUBLICKEY_STATE_VALID=1,
202 SSH_PUBLICKEY_STATE_WRONG=2
203};
204
205/* Status flags */
207#define SSH_CLOSED 0x01
209#define SSH_READ_PENDING 0x02
211#define SSH_CLOSED_ERROR 0x04
213#define SSH_WRITE_PENDING 0x08
214
215 enum ssh_server_known_e {
216 SSH_SERVER_ERROR=-1,
217 SSH_SERVER_NOT_KNOWN=0,
218 SSH_SERVER_KNOWN_OK,
219 SSH_SERVER_KNOWN_CHANGED,
220 SSH_SERVER_FOUND_OTHER,
221 SSH_SERVER_FILE_NOT_FOUND
222};
223
224 enum ssh_known_hosts_e {
228 SSH_KNOWN_HOSTS_ERROR = -2,
229
234 SSH_KNOWN_HOSTS_NOT_FOUND = -1,
235
240 SSH_KNOWN_HOSTS_UNKNOWN = 0,
241
245 SSH_KNOWN_HOSTS_OK,
246
252 SSH_KNOWN_HOSTS_CHANGED,
253
258 SSH_KNOWN_HOSTS_OTHER,
259};
260
261#ifndef MD5_DIGEST_LEN
262 #define MD5_DIGEST_LEN 16
263#endif
264/* errors */
265
266 enum ssh_error_types_e {
267 SSH_NO_ERROR=0,
268 SSH_REQUEST_DENIED,
269 SSH_FATAL,
270 SSH_EINTR
271};
272
273/* some types for keys */
274 enum ssh_keytypes_e{
275 SSH_KEYTYPE_UNKNOWN=0,
276 SSH_KEYTYPE_DSS=1, /* deprecated */
277 SSH_KEYTYPE_RSA,
278 SSH_KEYTYPE_RSA1,
279 SSH_KEYTYPE_ECDSA, /* deprecated */
280 SSH_KEYTYPE_ED25519,
281 SSH_KEYTYPE_DSS_CERT01, /* deprecated */
282 SSH_KEYTYPE_RSA_CERT01,
283 SSH_KEYTYPE_ECDSA_P256,
284 SSH_KEYTYPE_ECDSA_P384,
285 SSH_KEYTYPE_ECDSA_P521,
286 SSH_KEYTYPE_ECDSA_P256_CERT01,
287 SSH_KEYTYPE_ECDSA_P384_CERT01,
288 SSH_KEYTYPE_ECDSA_P521_CERT01,
289 SSH_KEYTYPE_ED25519_CERT01,
290 SSH_KEYTYPE_SK_ECDSA,
291 SSH_KEYTYPE_SK_ECDSA_CERT01,
292 SSH_KEYTYPE_SK_ED25519,
293 SSH_KEYTYPE_SK_ED25519_CERT01,
294};
295
296 enum ssh_keycmp_e {
297 SSH_KEY_CMP_PUBLIC = 0,
298 SSH_KEY_CMP_PRIVATE = 1,
299 SSH_KEY_CMP_CERTIFICATE = 2,
300};
301
302#define SSH_ADDRSTRLEN 46
303
304 struct ssh_knownhosts_entry {
305 char *hostname;
306 char *unparsed;
307 ssh_key publickey;
308 char *comment;
309};
310
311
312/* Error return codes */
313#define SSH_OK 0 /* No error */
314#define SSH_ERROR -1 /* Error of some kind */
315#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
316#define SSH_EOF -127 /* We have already a eof */
317
324 enum {
327 SSH_LOG_NOLOG=0,
330 SSH_LOG_WARNING,
333 SSH_LOG_PROTOCOL,
336 SSH_LOG_PACKET,
339 SSH_LOG_FUNCTIONS
340};
342#define SSH_LOG_RARE SSH_LOG_WARNING
343
352#define SSH_LOG_NONE 0
354#define SSH_LOG_WARN 1
356#define SSH_LOG_INFO 2
358#define SSH_LOG_DEBUG 3
360#define SSH_LOG_TRACE 4
361
364 enum ssh_control_master_options_e {
365 SSH_CONTROL_MASTER_NO,
366 SSH_CONTROL_MASTER_AUTO,
367 SSH_CONTROL_MASTER_YES,
368 SSH_CONTROL_MASTER_ASK,
369 SSH_CONTROL_MASTER_AUTOASK
370};
371
372 enum ssh_options_e {
373 SSH_OPTIONS_HOST,
374 SSH_OPTIONS_PORT,
375 SSH_OPTIONS_PORT_STR,
376 SSH_OPTIONS_FD,
377 SSH_OPTIONS_USER,
378 SSH_OPTIONS_SSH_DIR,
379 SSH_OPTIONS_IDENTITY,
380 SSH_OPTIONS_ADD_IDENTITY,
381 SSH_OPTIONS_KNOWNHOSTS,
382 SSH_OPTIONS_TIMEOUT,
383 SSH_OPTIONS_TIMEOUT_USEC,
384 SSH_OPTIONS_SSH1,
385 SSH_OPTIONS_SSH2,
386 SSH_OPTIONS_LOG_VERBOSITY,
387 SSH_OPTIONS_LOG_VERBOSITY_STR,
388 SSH_OPTIONS_CIPHERS_C_S,
389 SSH_OPTIONS_CIPHERS_S_C,
390 SSH_OPTIONS_COMPRESSION_C_S,
391 SSH_OPTIONS_COMPRESSION_S_C,
392 SSH_OPTIONS_PROXYCOMMAND,
393 SSH_OPTIONS_BINDADDR,
394 SSH_OPTIONS_STRICTHOSTKEYCHECK,
395 SSH_OPTIONS_COMPRESSION,
396 SSH_OPTIONS_COMPRESSION_LEVEL,
397 SSH_OPTIONS_KEY_EXCHANGE,
398 SSH_OPTIONS_HOSTKEYS,
399 SSH_OPTIONS_GSSAPI_SERVER_IDENTITY,
400 SSH_OPTIONS_GSSAPI_CLIENT_IDENTITY,
401 SSH_OPTIONS_GSSAPI_DELEGATE_CREDENTIALS,
402 SSH_OPTIONS_HMAC_C_S,
403 SSH_OPTIONS_HMAC_S_C,
404 SSH_OPTIONS_PASSWORD_AUTH,
405 SSH_OPTIONS_PUBKEY_AUTH,
406 SSH_OPTIONS_KBDINT_AUTH,
407 SSH_OPTIONS_GSSAPI_AUTH,
408 SSH_OPTIONS_GLOBAL_KNOWNHOSTS,
409 SSH_OPTIONS_NODELAY,
410 SSH_OPTIONS_PUBLICKEY_ACCEPTED_TYPES,
411 SSH_OPTIONS_PROCESS_CONFIG,
412 SSH_OPTIONS_REKEY_DATA,
413 SSH_OPTIONS_REKEY_TIME,
414 SSH_OPTIONS_RSA_MIN_SIZE,
415 SSH_OPTIONS_IDENTITY_AGENT,
416 SSH_OPTIONS_IDENTITIES_ONLY,
417 SSH_OPTIONS_CONTROL_MASTER,
418 SSH_OPTIONS_CONTROL_PATH,
419 SSH_OPTIONS_CERTIFICATE,
420 SSH_OPTIONS_PROXYJUMP,
421 SSH_OPTIONS_PROXYJUMP_CB_LIST_APPEND,
422};
423
424 enum {
426 SSH_SCP_WRITE,
428 SSH_SCP_READ,
429 SSH_SCP_RECURSIVE=0x10
430};
431
432 enum ssh_scp_request_types {
434 SSH_SCP_REQUEST_NEWDIR=1,
436 SSH_SCP_REQUEST_NEWFILE,
438 SSH_SCP_REQUEST_EOF,
440 SSH_SCP_REQUEST_ENDDIR,
442 SSH_SCP_REQUEST_WARNING
443};
444
445 enum ssh_connector_flags_e {
447 SSH_CONNECTOR_STDOUT = 1,
448 SSH_CONNECTOR_STDINOUT = 1,
450 SSH_CONNECTOR_STDERR = 2,
452 SSH_CONNECTOR_BOTH = 3
453};
454
455LIBSSH_API int ssh_blocking_flush(ssh_session session, int timeout);
456LIBSSH_API ssh_channel ssh_channel_accept_x11(ssh_channel channel, int timeout_ms);
457LIBSSH_API int ssh_channel_change_pty_size(ssh_channel channel,int cols,int rows);
458LIBSSH_API int ssh_channel_close(ssh_channel channel);
459#define SSH_CHANNEL_FREE(x) \
460 do { \
461 if ((x) != NULL) { \
462 ssh_channel_free(x); \
463 (x) = NULL; \
464 } \
465 } while (0)
466LIBSSH_API void ssh_channel_free(ssh_channel channel);
467LIBSSH_API int ssh_channel_get_exit_state(ssh_channel channel,
468 uint32_t *pexit_code,
469 char **pexit_signal,
470 int *pcore_dumped);
471SSH_DEPRECATED LIBSSH_API int ssh_channel_get_exit_status(ssh_channel channel);
472LIBSSH_API ssh_session ssh_channel_get_session(ssh_channel channel);
473LIBSSH_API int ssh_channel_is_closed(ssh_channel channel);
474LIBSSH_API int ssh_channel_is_eof(ssh_channel channel);
475LIBSSH_API int ssh_channel_is_open(ssh_channel channel);
476LIBSSH_API ssh_channel ssh_channel_new(ssh_session session);
477LIBSSH_API int ssh_channel_open_auth_agent(ssh_channel channel);
478LIBSSH_API int ssh_channel_open_forward(ssh_channel channel, const char *remotehost,
479 int remoteport, const char *sourcehost, int localport);
480LIBSSH_API int ssh_channel_open_forward_unix(ssh_channel channel, const char *remotepath,
481 const char *sourcehost, int localport);
482LIBSSH_API int ssh_channel_open_session(ssh_channel channel);
483LIBSSH_API int ssh_channel_open_x11(ssh_channel channel, const char *orig_addr, int orig_port);
484LIBSSH_API int ssh_channel_poll(ssh_channel channel, int is_stderr);
485LIBSSH_API int ssh_channel_poll_timeout(ssh_channel channel, int timeout, int is_stderr);
486LIBSSH_API int ssh_channel_read(ssh_channel channel, void *dest, uint32_t count, int is_stderr);
487LIBSSH_API int ssh_channel_read_timeout(ssh_channel channel, void *dest, uint32_t count, int is_stderr, int timeout_ms);
488LIBSSH_API int ssh_channel_read_nonblocking(ssh_channel channel, void *dest, uint32_t count,
489 int is_stderr);
490LIBSSH_API int ssh_channel_request_env(ssh_channel channel, const char *name, const char *value);
491LIBSSH_API int ssh_channel_request_exec(ssh_channel channel, const char *cmd);
492LIBSSH_API int ssh_channel_request_pty(ssh_channel channel);
493LIBSSH_API int ssh_channel_request_pty_size(ssh_channel channel, const char *term,
494 int cols, int rows);
495LIBSSH_API int ssh_channel_request_pty_size_modes(ssh_channel channel, const char *term,
496 int cols, int rows, const unsigned char* modes, size_t modes_len);
497LIBSSH_API int ssh_channel_request_shell(ssh_channel channel);
498LIBSSH_API int ssh_channel_request_send_signal(ssh_channel channel, const char *signum);
499LIBSSH_API int ssh_channel_request_send_break(ssh_channel channel, uint32_t length);
500LIBSSH_API int ssh_channel_request_sftp(ssh_channel channel);
501LIBSSH_API int ssh_channel_request_subsystem(ssh_channel channel, const char *subsystem);
502LIBSSH_API int ssh_channel_request_x11(ssh_channel channel, int single_connection, const char *protocol,
503 const char *cookie, int screen_number);
504LIBSSH_API int ssh_channel_request_auth_agent(ssh_channel channel);
505LIBSSH_API int ssh_channel_send_eof(ssh_channel channel);
506LIBSSH_API void ssh_channel_set_blocking(ssh_channel channel, int blocking);
507LIBSSH_API void ssh_channel_set_counter(ssh_channel channel,
508 ssh_counter counter);
509LIBSSH_API int ssh_channel_write(ssh_channel channel, const void *data, uint32_t len);
510LIBSSH_API int ssh_channel_write_stderr(ssh_channel channel,
511 const void *data,
512 uint32_t len);
513LIBSSH_API uint32_t ssh_channel_window_size(ssh_channel channel);
514
515LIBSSH_API char *ssh_basename (const char *path);
516LIBSSH_API void ssh_clean_pubkey_hash(unsigned char **hash);
517LIBSSH_API int ssh_connect(ssh_session session);
518
519LIBSSH_API ssh_connector ssh_connector_new(ssh_session session);
520LIBSSH_API void ssh_connector_free(ssh_connector connector);
521LIBSSH_API int ssh_connector_set_in_channel(ssh_connector connector,
522 ssh_channel channel,
523 enum ssh_connector_flags_e flags);
524LIBSSH_API int ssh_connector_set_out_channel(ssh_connector connector,
525 ssh_channel channel,
526 enum ssh_connector_flags_e flags);
527LIBSSH_API void ssh_connector_set_in_fd(ssh_connector connector, socket_t fd);
528LIBSSH_API void ssh_connector_set_out_fd(ssh_connector connector, socket_t fd);
529
530LIBSSH_API const char *ssh_copyright(void);
531LIBSSH_API void ssh_disconnect(ssh_session session);
532LIBSSH_API char *ssh_dirname (const char *path);
533LIBSSH_API int ssh_finalize(void);
534
535/* REVERSE PORT FORWARDING */
536LIBSSH_API ssh_channel ssh_channel_open_forward_port(ssh_session session,
537 int timeout_ms,
538 int *destination_port,
539 char **originator,
540 int *originator_port);
541SSH_DEPRECATED LIBSSH_API ssh_channel ssh_channel_accept_forward(ssh_session session,
542 int timeout_ms,
543 int *destination_port);
544LIBSSH_API int ssh_channel_cancel_forward(ssh_session session,
545 const char *address,
546 int port);
547LIBSSH_API int ssh_channel_listen_forward(ssh_session session,
548 const char *address,
549 int port,
550 int *bound_port);
551
552LIBSSH_API void ssh_free(ssh_session session);
553LIBSSH_API const char *ssh_get_disconnect_message(ssh_session session);
554LIBSSH_API const char *ssh_get_error(void *error);
555LIBSSH_API int ssh_get_error_code(void *error);
556LIBSSH_API socket_t ssh_get_fd(ssh_session session);
557LIBSSH_API char *ssh_get_hexa(const unsigned char *what, size_t len);
558LIBSSH_API char *ssh_get_issue_banner(ssh_session session);
559LIBSSH_API int ssh_get_openssh_version(ssh_session session);
560LIBSSH_API int ssh_request_no_more_sessions(ssh_session session);
561
562LIBSSH_API int ssh_get_server_publickey(ssh_session session, ssh_key *key);
563
564 enum ssh_publickey_hash_type {
565 SSH_PUBLICKEY_HASH_SHA1,
566 SSH_PUBLICKEY_HASH_MD5,
567 SSH_PUBLICKEY_HASH_SHA256
568};
569LIBSSH_API int ssh_get_publickey_hash(const ssh_key key,
570 enum ssh_publickey_hash_type type,
571 unsigned char **hash,
572 size_t *hlen);
573
574/* DEPRECATED FUNCTIONS */
575SSH_DEPRECATED LIBSSH_API int ssh_get_pubkey_hash(ssh_session session, unsigned char **hash);
576SSH_DEPRECATED LIBSSH_API ssh_channel ssh_forward_accept(ssh_session session, int timeout_ms);
577SSH_DEPRECATED LIBSSH_API int ssh_forward_cancel(ssh_session session, const char *address, int port);
578SSH_DEPRECATED LIBSSH_API int ssh_forward_listen(ssh_session session, const char *address, int port, int *bound_port);
579SSH_DEPRECATED LIBSSH_API int ssh_get_publickey(ssh_session session, ssh_key *key);
580SSH_DEPRECATED LIBSSH_API int ssh_write_knownhost(ssh_session session);
581SSH_DEPRECATED LIBSSH_API char *ssh_dump_knownhost(ssh_session session);
582SSH_DEPRECATED LIBSSH_API int ssh_is_server_known(ssh_session session);
583SSH_DEPRECATED LIBSSH_API void ssh_print_hexa(const char *descr, const unsigned char *what, size_t len);
584SSH_DEPRECATED LIBSSH_API int ssh_channel_select(ssh_channel *readchans, ssh_channel *writechans, ssh_channel *exceptchans, struct
585 timeval * timeout);
586
587SSH_DEPRECATED LIBSSH_API int ssh_scp_accept_request(ssh_scp scp);
588SSH_DEPRECATED LIBSSH_API int ssh_scp_close(ssh_scp scp);
589SSH_DEPRECATED LIBSSH_API int ssh_scp_deny_request(ssh_scp scp, const char *reason);
590SSH_DEPRECATED LIBSSH_API void ssh_scp_free(ssh_scp scp);
591SSH_DEPRECATED LIBSSH_API int ssh_scp_init(ssh_scp scp);
592SSH_DEPRECATED LIBSSH_API int ssh_scp_leave_directory(ssh_scp scp);
593SSH_DEPRECATED LIBSSH_API ssh_scp ssh_scp_new(ssh_session session, int mode, const char *location);
594SSH_DEPRECATED LIBSSH_API int ssh_scp_pull_request(ssh_scp scp);
595SSH_DEPRECATED LIBSSH_API int ssh_scp_push_directory(ssh_scp scp, const char *dirname, int mode);
596SSH_DEPRECATED LIBSSH_API int ssh_scp_push_file(ssh_scp scp, const char *filename, size_t size, int perms);
597SSH_DEPRECATED LIBSSH_API int ssh_scp_push_file64(ssh_scp scp, const char *filename, uint64_t size, int perms);
598SSH_DEPRECATED LIBSSH_API int ssh_scp_read(ssh_scp scp, void *buffer, size_t size);
599SSH_DEPRECATED LIBSSH_API const char *ssh_scp_request_get_filename(ssh_scp scp);
600SSH_DEPRECATED LIBSSH_API int ssh_scp_request_get_permissions(ssh_scp scp);
601SSH_DEPRECATED LIBSSH_API size_t ssh_scp_request_get_size(ssh_scp scp);
602SSH_DEPRECATED LIBSSH_API uint64_t ssh_scp_request_get_size64(ssh_scp scp);
603SSH_DEPRECATED LIBSSH_API const char *ssh_scp_request_get_warning(ssh_scp scp);
604SSH_DEPRECATED LIBSSH_API int ssh_scp_write(ssh_scp scp, const void *buffer, size_t len);
605
606
607LIBSSH_API int ssh_get_random(void *where,int len,int strong);
608LIBSSH_API int ssh_get_version(ssh_session session);
609LIBSSH_API int ssh_get_status(ssh_session session);
610LIBSSH_API int ssh_get_poll_flags(ssh_session session);
611LIBSSH_API int ssh_init(void);
612LIBSSH_API int ssh_is_blocking(ssh_session session);
613LIBSSH_API int ssh_is_connected(ssh_session session);
614
615/* KNOWN HOSTS */
616LIBSSH_API void ssh_knownhosts_entry_free(struct ssh_knownhosts_entry *entry);
617#define SSH_KNOWNHOSTS_ENTRY_FREE(e) do { \
618 if ((e) != NULL) { \
619 ssh_knownhosts_entry_free(e); \
620 e = NULL; \
621 } \
622} while(0)
623
624LIBSSH_API int ssh_known_hosts_parse_line(const char *host,
625 const char *line,
626 struct ssh_knownhosts_entry **entry);
627LIBSSH_API enum ssh_known_hosts_e ssh_session_has_known_hosts_entry(ssh_session session);
628
629LIBSSH_API int ssh_session_export_known_hosts_entry(ssh_session session,
630 char **pentry_string);
631LIBSSH_API int ssh_session_update_known_hosts(ssh_session session);
632
633LIBSSH_API enum ssh_known_hosts_e ssh_session_get_known_hosts_entry(ssh_session session,
634 struct ssh_knownhosts_entry **pentry);
635LIBSSH_API enum ssh_known_hosts_e ssh_session_is_known_server(ssh_session session);
636
637/* LOGGING */
638LIBSSH_API int ssh_set_log_level(int level);
639LIBSSH_API int ssh_get_log_level(void);
640LIBSSH_API void *ssh_get_log_userdata(void);
641LIBSSH_API int ssh_set_log_userdata(void *data);
642LIBSSH_API void ssh_vlog(int verbosity,
643 const char *function,
644 const char *format,
645 va_list *va) PRINTF_ATTRIBUTE(3, 0);
646LIBSSH_API void _ssh_log(int verbosity,
647 const char *function,
648 const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
649
650/* legacy */
651SSH_DEPRECATED LIBSSH_API void ssh_log(ssh_session session,
652 int prioriry,
653 const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
654
655LIBSSH_API ssh_channel ssh_message_channel_request_open_reply_accept(ssh_message msg);
656LIBSSH_API int ssh_message_channel_request_open_reply_accept_channel(ssh_message msg, ssh_channel chan);
657LIBSSH_API int ssh_message_channel_request_reply_success(ssh_message msg);
658#define SSH_MESSAGE_FREE(x) \
659 do { if ((x) != NULL) { ssh_message_free(x); (x) = NULL; } } while(0)
660LIBSSH_API void ssh_message_free(ssh_message msg);
661LIBSSH_API ssh_message ssh_message_get(ssh_session session);
662LIBSSH_API int ssh_message_subtype(ssh_message msg);
663LIBSSH_API int ssh_message_type(ssh_message msg);
664LIBSSH_API int ssh_mkdir (const char *pathname, mode_t mode);
665LIBSSH_API ssh_session ssh_new(void);
666
667LIBSSH_API int ssh_options_copy(ssh_session src, ssh_session *dest);
668LIBSSH_API int ssh_options_getopt(ssh_session session, int *argcptr, char **argv);
669LIBSSH_API int ssh_options_parse_config(ssh_session session, const char *filename);
670LIBSSH_API int ssh_options_set(ssh_session session, enum ssh_options_e type,
671 const void *value);
672LIBSSH_API int ssh_options_get(ssh_session session, enum ssh_options_e type,
673 char **value);
674LIBSSH_API int ssh_options_get_port(ssh_session session, unsigned int * port_target);
675LIBSSH_API int ssh_pcap_file_close(ssh_pcap_file pcap);
676LIBSSH_API void ssh_pcap_file_free(ssh_pcap_file pcap);
677LIBSSH_API ssh_pcap_file ssh_pcap_file_new(void);
678LIBSSH_API int ssh_pcap_file_open(ssh_pcap_file pcap, const char *filename);
679
699 typedef int (*ssh_auth_callback) (const char *prompt, char *buf, size_t len,
700 int echo, int verify, void *userdata);
701
704 enum ssh_file_format_e {
705 SSH_FILE_FORMAT_DEFAULT = 0,
706 SSH_FILE_FORMAT_OPENSSH,
707 SSH_FILE_FORMAT_PEM,
708};
709
710LIBSSH_API ssh_key ssh_key_new(void);
711#define SSH_KEY_FREE(x) \
712 do { if ((x) != NULL) { ssh_key_free(x); x = NULL; } } while(0)
713LIBSSH_API void ssh_key_free (ssh_key key);
714LIBSSH_API enum ssh_keytypes_e ssh_key_type(const ssh_key key);
715LIBSSH_API const char *ssh_key_type_to_char(enum ssh_keytypes_e type);
716LIBSSH_API enum ssh_keytypes_e ssh_key_type_from_name(const char *name);
717LIBSSH_API int ssh_key_is_public(const ssh_key k);
718LIBSSH_API int ssh_key_is_private(const ssh_key k);
719LIBSSH_API int ssh_key_cmp(const ssh_key k1,
720 const ssh_key k2,
721 enum ssh_keycmp_e what);
722LIBSSH_API ssh_key ssh_key_dup(const ssh_key key);
723
724LIBSSH_API int ssh_pki_generate(enum ssh_keytypes_e type, int parameter,
725 ssh_key *pkey);
726LIBSSH_API int ssh_pki_import_privkey_base64(const char *b64_key,
727 const char *passphrase,
728 ssh_auth_callback auth_fn,
729 void *auth_data,
730 ssh_key *pkey);
731LIBSSH_API int ssh_pki_export_privkey_base64(const ssh_key privkey,
732 const char *passphrase,
733 ssh_auth_callback auth_fn,
734 void *auth_data,
735 char **b64_key);
736LIBSSH_API int
737 ssh_pki_export_privkey_base64_format(const ssh_key privkey,
738 const char *passphrase,
739 ssh_auth_callback auth_fn,
740 void *auth_data,
741 char **b64_key,
742 enum ssh_file_format_e format);
743LIBSSH_API int ssh_pki_import_privkey_file(const char *filename,
744 const char *passphrase,
745 ssh_auth_callback auth_fn,
746 void *auth_data,
747 ssh_key *pkey);
748LIBSSH_API int ssh_pki_export_privkey_file(const ssh_key privkey,
749 const char *passphrase,
750 ssh_auth_callback auth_fn,
751 void *auth_data,
752 const char *filename);
753LIBSSH_API int
754 ssh_pki_export_privkey_file_format(const ssh_key privkey,
755 const char *passphrase,
756 ssh_auth_callback auth_fn,
757 void *auth_data,
758 const char *filename,
759 enum ssh_file_format_e format);
760
761LIBSSH_API int ssh_pki_copy_cert_to_privkey(const ssh_key cert_key,
762 ssh_key privkey);
763
764LIBSSH_API int ssh_pki_import_pubkey_base64(const char *b64_key,
765 enum ssh_keytypes_e type,
766 ssh_key *pkey);
767LIBSSH_API int ssh_pki_import_pubkey_file(const char *filename,
768 ssh_key *pkey);
769
770LIBSSH_API int ssh_pki_import_cert_base64(const char *b64_cert,
771 enum ssh_keytypes_e type,
772 ssh_key *pkey);
773LIBSSH_API int ssh_pki_import_cert_file(const char *filename,
774 ssh_key *pkey);
775
776LIBSSH_API int ssh_pki_export_privkey_to_pubkey(const ssh_key privkey,
777 ssh_key *pkey);
778LIBSSH_API int ssh_pki_export_pubkey_base64(const ssh_key key,
779 char **b64_key);
780LIBSSH_API int ssh_pki_export_pubkey_file(const ssh_key key,
781 const char *filename);
782
783LIBSSH_API const char *ssh_pki_key_ecdsa_name(const ssh_key key);
784
785LIBSSH_API char *ssh_get_fingerprint_hash(enum ssh_publickey_hash_type type,
786 unsigned char *hash,
787 size_t len);
788LIBSSH_API void ssh_print_hash(enum ssh_publickey_hash_type type, unsigned char *hash, size_t len);
789LIBSSH_API int ssh_send_ignore (ssh_session session, const char *data);
790LIBSSH_API int ssh_send_debug (ssh_session session, const char *message, int always_display);
791LIBSSH_API void ssh_gssapi_set_creds(ssh_session session, const ssh_gssapi_creds creds);
792LIBSSH_API int ssh_select(ssh_channel *channels, ssh_channel *outchannels, socket_t maxfd,
793 fd_set *readfds, struct timeval *timeout);
794LIBSSH_API int ssh_service_request(ssh_session session, const char *service);
795LIBSSH_API int ssh_set_agent_channel(ssh_session session, ssh_channel channel);
796LIBSSH_API int ssh_set_agent_socket(ssh_session session, socket_t fd);
797LIBSSH_API void ssh_set_blocking(ssh_session session, int blocking);
798LIBSSH_API void ssh_set_counters(ssh_session session, ssh_counter scounter,
799 ssh_counter rcounter);
800LIBSSH_API void ssh_set_fd_except(ssh_session session);
801LIBSSH_API void ssh_set_fd_toread(ssh_session session);
802LIBSSH_API void ssh_set_fd_towrite(ssh_session session);
803LIBSSH_API void ssh_silent_disconnect(ssh_session session);
804LIBSSH_API int ssh_set_pcap_file(ssh_session session, ssh_pcap_file pcapfile);
805
806/* USERAUTH */
807LIBSSH_API int ssh_userauth_none(ssh_session session, const char *username);
808LIBSSH_API int ssh_userauth_list(ssh_session session, const char *username);
809LIBSSH_API int ssh_userauth_try_publickey(ssh_session session,
810 const char *username,
811 const ssh_key pubkey);
812LIBSSH_API int ssh_userauth_publickey(ssh_session session,
813 const char *username,
814 const ssh_key privkey);
815LIBSSH_API int ssh_userauth_agent(ssh_session session,
816 const char *username);
817LIBSSH_API int ssh_userauth_publickey_auto_get_current_identity(ssh_session session,
818 char** value);
819LIBSSH_API int ssh_userauth_publickey_auto(ssh_session session,
820 const char *username,
821 const char *passphrase);
822LIBSSH_API int ssh_userauth_password(ssh_session session,
823 const char *username,
824 const char *password);
825
826LIBSSH_API int ssh_userauth_kbdint(ssh_session session, const char *user, const char *submethods);
827LIBSSH_API const char *ssh_userauth_kbdint_getinstruction(ssh_session session);
828LIBSSH_API const char *ssh_userauth_kbdint_getname(ssh_session session);
829LIBSSH_API int ssh_userauth_kbdint_getnprompts(ssh_session session);
830LIBSSH_API const char *ssh_userauth_kbdint_getprompt(ssh_session session, unsigned int i, char *echo);
831LIBSSH_API int ssh_userauth_kbdint_getnanswers(ssh_session session);
832LIBSSH_API const char *ssh_userauth_kbdint_getanswer(ssh_session session, unsigned int i);
833LIBSSH_API int ssh_userauth_kbdint_setanswer(ssh_session session, unsigned int i,
834 const char *answer);
835LIBSSH_API int ssh_userauth_gssapi(ssh_session session);
836LIBSSH_API const char *ssh_version(int req_version);
837
838LIBSSH_API void ssh_string_burn(ssh_string str);
839LIBSSH_API ssh_string ssh_string_copy(ssh_string str);
840LIBSSH_API void *ssh_string_data(ssh_string str);
841LIBSSH_API int ssh_string_fill(ssh_string str, const void *data, size_t len);
842#define SSH_STRING_FREE(x) \
843 do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
844LIBSSH_API void ssh_string_free(ssh_string str);
845LIBSSH_API ssh_string ssh_string_from_char(const char *what);
846LIBSSH_API size_t ssh_string_len(ssh_string str);
847LIBSSH_API ssh_string ssh_string_new(size_t size);
848LIBSSH_API const char *ssh_string_get_char(ssh_string str);
849LIBSSH_API char *ssh_string_to_char(ssh_string str);
850#define SSH_STRING_FREE_CHAR(x) \
851 do { if ((x) != NULL) { ssh_string_free_char(x); x = NULL; } } while(0)
852LIBSSH_API void ssh_string_free_char(char *s);
853
854LIBSSH_API int ssh_getpass(const char *prompt, char *buf, size_t len, int echo,
855 int verify);
856
857
858 typedef int (*ssh_event_callback)(socket_t fd, int revents, void *userdata);
859
860LIBSSH_API ssh_event ssh_event_new(void);
861LIBSSH_API int ssh_event_add_fd(ssh_event event, socket_t fd, short events,
862 ssh_event_callback cb, void *userdata);
863LIBSSH_API int ssh_event_add_session(ssh_event event, ssh_session session);
864LIBSSH_API int ssh_event_add_connector(ssh_event event, ssh_connector connector);
865LIBSSH_API int ssh_event_dopoll(ssh_event event, int timeout);
866LIBSSH_API int ssh_event_remove_fd(ssh_event event, socket_t fd);
867LIBSSH_API int ssh_event_remove_session(ssh_event event, ssh_session session);
868LIBSSH_API int ssh_event_remove_connector(ssh_event event, ssh_connector connector);
869LIBSSH_API void ssh_event_free(ssh_event event);
870LIBSSH_API const char* ssh_get_clientbanner(ssh_session session);
871LIBSSH_API const char* ssh_get_serverbanner(ssh_session session);
872LIBSSH_API const char* ssh_get_kex_algo(ssh_session session);
873LIBSSH_API const char* ssh_get_cipher_in(ssh_session session);
874LIBSSH_API const char* ssh_get_cipher_out(ssh_session session);
875LIBSSH_API const char* ssh_get_hmac_in(ssh_session session);
876LIBSSH_API const char* ssh_get_hmac_out(ssh_session session);
877
878LIBSSH_API ssh_buffer ssh_buffer_new(void);
879LIBSSH_API void ssh_buffer_free(ssh_buffer buffer);
880#define SSH_BUFFER_FREE(x) \
881 do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
882LIBSSH_API int ssh_buffer_reinit(ssh_buffer buffer);
883LIBSSH_API int ssh_buffer_add_data(ssh_buffer buffer, const void *data, uint32_t len);
884LIBSSH_API uint32_t ssh_buffer_get_data(ssh_buffer buffer, void *data, uint32_t requestedlen);
885LIBSSH_API void *ssh_buffer_get(ssh_buffer buffer);
886LIBSSH_API uint32_t ssh_buffer_get_len(ssh_buffer buffer);
887LIBSSH_API int ssh_session_set_disconnect_message(ssh_session session, const char *message);
888
889#ifndef LIBSSH_LEGACY_0_4
890#include "libssh/legacy.h"
891#endif
892
893#ifdef __cplusplus
894}
895#endif
896#endif /* _LIBSSH_H */
ssh_userauth_kbdint_getprompt
LIBSSH_API const char * ssh_userauth_kbdint_getprompt(ssh_session session, unsigned int i, char *echo)
Get a prompt from a message block.
Definition auth.c:2174
ssh_userauth_gssapi
LIBSSH_API int ssh_userauth_gssapi(ssh_session session)
Try to authenticate through the "gssapi-with-mic" method.
Definition auth.c:2301
ssh_userauth_list
LIBSSH_API int ssh_userauth_list(ssh_session session, const char *username)
Get available authentication methods from the server.
Definition auth.c:379
ssh_userauth_kbdint_getnanswers
LIBSSH_API int ssh_userauth_kbdint_getnanswers(ssh_session session)
Get the number of answers the client has given.
Definition auth.c:2202
ssh_auth_callback
int(* ssh_auth_callback)(const char *prompt, char *buf, size_t len, int echo, int verify, void *userdata)
SSH authentication callback for password and publickey auth.
Definition libssh.h:699
ssh_userauth_kbdint_getanswer
LIBSSH_API const char * ssh_userauth_kbdint_getanswer(ssh_session session, unsigned int i)
Get the answer to a question from a message block.
Definition auth.c:2220
ssh_userauth_password
LIBSSH_API int ssh_userauth_password(ssh_session session, const char *username, const char *password)
Try to authenticate by password.
Definition auth.c:1616
ssh_userauth_publickey_auto
LIBSSH_API int ssh_userauth_publickey_auto(ssh_session session, const char *username, const char *passphrase)
Tries to automatically authenticate with public key and "none".
Definition auth.c:1272
ssh_userauth_none
LIBSSH_API int ssh_userauth_none(ssh_session session, const char *username)
Try to authenticate through the "none" method.
Definition auth.c:409
ssh_userauth_try_publickey
LIBSSH_API int ssh_userauth_try_publickey(ssh_session session, const char *username, const ssh_key pubkey)
Try to authenticate with the given public key.
Definition auth.c:493
ssh_set_agent_channel
LIBSSH_API int ssh_set_agent_channel(ssh_session session, ssh_channel channel)
sets the SSH agent channel. The SSH agent channel will be used to authenticate this client using an a...
Definition agent.c:171
ssh_userauth_kbdint_getname
LIBSSH_API const char * ssh_userauth_kbdint_getname(ssh_session session)
Get the "name" of the message block.
Definition auth.c:2113
ssh_userauth_kbdint
LIBSSH_API int ssh_userauth_kbdint(ssh_session session, const char *user, const char *submethods)
Try to authenticate through the "keyboard-interactive" method.
Definition auth.c:2046
ssh_userauth_kbdint_setanswer
LIBSSH_API int ssh_userauth_kbdint_setanswer(ssh_session session, unsigned int i, const char *answer)
Set the answer for a question from a message block.
Definition auth.c:2253
ssh_userauth_agent
LIBSSH_API int ssh_userauth_agent(ssh_session session, const char *username)
Try to do public key authentication with ssh agent.
Definition auth.c:908
ssh_userauth_publickey_auto_get_current_identity
LIBSSH_API int ssh_userauth_publickey_auto_get_current_identity(ssh_session session, char **value)
Get the identity that is currently being processed by ssh_userauth_publickey_auto()
Definition auth.c:1209
ssh_set_agent_socket
LIBSSH_API int ssh_set_agent_socket(ssh_session session, socket_t fd)
sets the SSH agent socket. The SSH agent will be used to authenticate this client using the given soc...
Definition agent.c:190
ssh_userauth_publickey
LIBSSH_API int ssh_userauth_publickey(ssh_session session, const char *username, const ssh_key privkey)
Authenticate with public/private key or certificate.
Definition auth.c:623
ssh_userauth_kbdint_getnprompts
LIBSSH_API int ssh_userauth_kbdint_getnprompts(ssh_session session)
Get the number of prompts (questions) the server has given.
Definition auth.c:2090
ssh_userauth_kbdint_getinstruction
LIBSSH_API const char * ssh_userauth_kbdint_getinstruction(ssh_session session)
Get the "instruction" of the message block.
Definition auth.c:2137
ssh_buffer_new
LIBSSH_API ssh_buffer ssh_buffer_new(void)
Create a new SSH buffer.
Definition buffer.c:120
ssh_channel_request_subsystem
LIBSSH_API int ssh_channel_request_subsystem(ssh_channel channel, const char *subsystem)
Request a subsystem (for example "sftp").
Definition channels.c:2120
ssh_channel_send_eof
LIBSSH_API int ssh_channel_send_eof(ssh_channel channel)
Send an end of file on the channel.
Definition channels.c:1360
ssh_channel_select
SSH_DEPRECATED LIBSSH_API int ssh_channel_select(ssh_channel *readchans, ssh_channel *writechans, ssh_channel *exceptchans, struct timeval *timeout)
Act like the standard select(2) on channels.
Definition channels.c:3589
ssh_channel_poll
LIBSSH_API int ssh_channel_poll(ssh_channel channel, int is_stderr)
Polls a channel for data to read.
Definition channels.c:3252
ssh_channel_get_exit_state
LIBSSH_API int ssh_channel_get_exit_state(ssh_channel channel, uint32_t *pexit_code, char **pexit_signal, int *pcore_dumped)
Get the exit state of the channel (error code from the executed instruction or signal).
Definition channels.c:3416
ssh_channel_set_blocking
LIBSSH_API void ssh_channel_set_blocking(ssh_channel channel, int blocking)
Put the channel into blocking or nonblocking mode.
Definition channels.c:1760
ssh_channel_close
LIBSSH_API int ssh_channel_close(ssh_channel channel)
Close a channel.
Definition channels.c:1421
ssh_channel_request_pty_size_modes
LIBSSH_API int ssh_channel_request_pty_size_modes(ssh_channel channel, const char *term, int cols, int rows, const unsigned char *modes, size_t modes_len)
Request a pty with a specific type and size.
Definition channels.c:1956
ssh_channel_read_timeout
LIBSSH_API int ssh_channel_read_timeout(ssh_channel channel, void *dest, uint32_t count, int is_stderr, int timeout_ms)
Reads data from a channel.
Definition channels.c:3080
ssh_channel_request_pty
LIBSSH_API int ssh_channel_request_pty(ssh_channel channel)
Request a PTY.
Definition channels.c:2037
ssh_channel_cancel_forward
LIBSSH_API int ssh_channel_cancel_forward(ssh_session session, const char *address, int port)
Sends the "cancel-tcpip-forward" global request to ask the server to cancel the tcpip-forward request...
Definition channels.c:2666
ssh_channel_request_sftp
LIBSSH_API int ssh_channel_request_sftp(ssh_channel channel)
Request sftp subsystem on the channel.
Definition channels.c:2170
ssh_channel_accept_forward
SSH_DEPRECATED LIBSSH_API ssh_channel ssh_channel_accept_forward(ssh_session session, int timeout_ms, int *destination_port)
Accept an incoming TCP/IP forwarding channel and get some information about incoming connection.
Definition channels.c:2623
ssh_channel_open_forward_port
LIBSSH_API ssh_channel ssh_channel_open_forward_port(ssh_session session, int timeout_ms, int *destination_port, char **originator, int *originator_port)
Accept an incoming TCP/IP forwarding channel and get information about incoming connection.
Definition channels.c:2647
ssh_channel_accept_x11
LIBSSH_API ssh_channel ssh_channel_accept_x11(ssh_channel channel, int timeout_ms)
Accept an X11 forwarding channel.
Definition channels.c:2348
ssh_channel_request_exec
LIBSSH_API int ssh_channel_request_exec(ssh_channel channel, const char *cmd)
Run a shell command without an interactive shell.
Definition channels.c:2789
ssh_channel_write
LIBSSH_API int ssh_channel_write(ssh_channel channel, const void *data, uint32_t len)
Blocking write on a channel.
Definition channels.c:1691
ssh_channel_open_auth_agent
LIBSSH_API int ssh_channel_open_auth_agent(ssh_channel channel)
Open an agent authentication forwarding channel. This type of channel can be opened by a server towar...
Definition channels.c:1080
ssh_channel_get_session
LIBSSH_API ssh_session ssh_channel_get_session(ssh_channel channel)
Recover the session in which belongs a channel.
Definition channels.c:3365
ssh_channel_listen_forward
LIBSSH_API int ssh_channel_listen_forward(ssh_session session, const char *address, int port, int *bound_port)
Sends the "tcpip-forward" global request to ask the server to begin listening for inbound connections...
Definition channels.c:2557
ssh_channel_request_env
LIBSSH_API int ssh_channel_request_env(ssh_channel channel, const char *name, const char *value)
Set environment variables.
Definition channels.c:2718
ssh_channel_write_stderr
LIBSSH_API int ssh_channel_write_stderr(ssh_channel channel, const void *data, uint32_t len)
Blocking write on a channel stderr.
Definition channels.c:3751
ssh_channel_open_forward_unix
LIBSSH_API int ssh_channel_open_forward_unix(ssh_channel channel, const char *remotepath, const char *sourcehost, int localport)
Open a TCP/IP - UNIX domain socket forwarding channel.
Definition channels.c:1192
ssh_channel_get_exit_status
SSH_DEPRECATED LIBSSH_API int ssh_channel_get_exit_status(ssh_channel channel)
Get the exit status of the channel (error code from the executed instruction).
Definition channels.c:3484
ssh_channel_request_send_signal
LIBSSH_API int ssh_channel_request_send_signal(ssh_channel channel, const char *signum)
Send a signal to remote process (as described in RFC 4254, section 6.9).
Definition channels.c:2855
ssh_channel_is_open
LIBSSH_API int ssh_channel_is_open(ssh_channel channel)
Check if the channel is open or not.
Definition channels.c:1705
ssh_channel_read_nonblocking
LIBSSH_API int ssh_channel_read_nonblocking(ssh_channel channel, void *dest, uint32_t count, int is_stderr)
Do a nonblocking read on the channel.
Definition channels.c:3191
ssh_channel_set_counter
LIBSSH_API void ssh_channel_set_counter(ssh_channel channel, ssh_counter counter)
Set the channel data counter.
Definition channels.c:3730
ssh_channel_is_closed
LIBSSH_API int ssh_channel_is_closed(ssh_channel channel)
Check if the channel is closed or not.
Definition channels.c:1722
ssh_channel_request_auth_agent
LIBSSH_API int ssh_channel_request_auth_agent(ssh_channel channel)
Send an "auth-agent-req" channel request over an existing session channel.
Definition channels.c:2364
ssh_channel_is_eof
LIBSSH_API int ssh_channel_is_eof(ssh_channel channel)
Check if remote has sent an EOF.
Definition channels.c:1737
ssh_channel_poll_timeout
LIBSSH_API int ssh_channel_poll_timeout(ssh_channel channel, int timeout, int is_stderr)
Polls a channel for data to read, waiting for a certain timeout.
Definition channels.c:3306
ssh_channel_read
LIBSSH_API int ssh_channel_read(ssh_channel channel, void *dest, uint32_t count, int is_stderr)
Reads data from a channel.
Definition channels.c:3051
ssh_channel_free
LIBSSH_API void ssh_channel_free(ssh_channel channel)
Close and free a channel.
Definition channels.c:1258
ssh_channel_new
LIBSSH_API ssh_channel ssh_channel_new(ssh_session session)
Allocate a new channel.
Definition channels.c:90
ssh_channel_window_size
LIBSSH_API uint32_t ssh_channel_window_size(ssh_channel channel)
Get the remote window size.
Definition channels.c:1673
ssh_channel_request_x11
LIBSSH_API int ssh_channel_request_x11(ssh_channel channel, int single_connection, const char *protocol, const char *cookie, int screen_number)
Sends the "x11-req" channel request over an existing session channel.
Definition channels.c:2224
ssh_channel_open_x11
LIBSSH_API int ssh_channel_open_x11(ssh_channel channel, const char *orig_addr, int orig_port)
Open a X11 channel.
Definition channels.c:3846
ssh_channel_open_forward
LIBSSH_API int ssh_channel_open_forward(ssh_channel channel, const char *remotehost, int remoteport, const char *sourcehost, int localport)
Open a TCP/IP forwarding channel.
Definition channels.c:1119
ssh_channel_request_shell
LIBSSH_API int ssh_channel_request_shell(ssh_channel channel)
Request a shell.
Definition channels.c:2097
ssh_channel_request_send_break
LIBSSH_API int ssh_channel_request_send_break(ssh_channel channel, uint32_t length)
Send a break signal to the server (as described in RFC 4335).
Definition channels.c:2900
ssh_channel_open_session
LIBSSH_API int ssh_channel_open_session(ssh_channel channel)
Open a session channel (suited for a shell, not TCP forwarding).
Definition channels.c:1052
ssh_channel_change_pty_size
LIBSSH_API int ssh_channel_change_pty_size(ssh_channel channel, int cols, int rows)
Change the size of the terminal associated to a channel.
Definition channels.c:2057
ssh_get_error_code
LIBSSH_API int ssh_get_error_code(void *error)
Retrieve the error code from the last error.
Definition error.c:148
ssh_get_error
LIBSSH_API const char * ssh_get_error(void *error)
Retrieve the error text message from the last error.
Definition error.c:128
ssh_set_log_userdata
LIBSSH_API int ssh_set_log_userdata(void *data)
Set the userdata for the logging function.
Definition log.c:255
ssh_get_log_userdata
LIBSSH_API void * ssh_get_log_userdata(void)
Get the userdata of the logging function.
Definition log.c:239
ssh_set_log_level
LIBSSH_API int ssh_set_log_level(int level)
Set the log level of the library.
Definition log.c:195
ssh_get_log_level
LIBSSH_API int ssh_get_log_level(void)
Get the log level of the library.
Definition log.c:210
SSH_LOG_WARNING
@ SSH_LOG_WARNING
Definition libssh.h:330
SSH_LOG_PACKET
@ SSH_LOG_PACKET
Definition libssh.h:336
SSH_LOG_PROTOCOL
@ SSH_LOG_PROTOCOL
Definition libssh.h:333
SSH_LOG_FUNCTIONS
@ SSH_LOG_FUNCTIONS
Definition libssh.h:339
SSH_LOG_NOLOG
@ SSH_LOG_NOLOG
Definition libssh.h:327
ssh_message_type
LIBSSH_API int ssh_message_type(ssh_message msg)
Get the type of the message.
Definition messages.c:591
ssh_message_subtype
LIBSSH_API int ssh_message_subtype(ssh_message msg)
Get the subtype of the message.
Definition messages.c:606
ssh_message_get
LIBSSH_API ssh_message ssh_message_get(ssh_session session)
Retrieve a SSH message from a SSH session.
Definition messages.c:558
ssh_message_free
LIBSSH_API void ssh_message_free(ssh_message msg)
Free a SSH message.
Definition messages.c:630
ssh_dirname
LIBSSH_API char * ssh_dirname(const char *path)
Parse directory component.
Definition misc.c:918
ssh_print_hexa
SSH_DEPRECATED LIBSSH_API void ssh_print_hexa(const char *descr, const unsigned char *what, size_t len)
Definition misc.c:484
ssh_mkdir
LIBSSH_API int ssh_mkdir(const char *pathname, mode_t mode)
Attempts to create a directory with the given pathname.
Definition misc.c:1029
ssh_get_random
LIBSSH_API int ssh_get_random(void *where, int len, int strong)
Get random bytes.
Definition getrandom_crypto.c:47
ssh_get_hexa
LIBSSH_API 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.
Definition misc.c:455
ssh_getpass
LIBSSH_API int ssh_getpass(const char *prompt, char *buf, size_t len, int echo, int verify)
Get a password from the console.
Definition getpass.c:214
ssh_version
LIBSSH_API const char * ssh_version(int req_version)
Check if libssh is the required version or get the version string.
Definition misc.c:706
ssh_basename
LIBSSH_API char * ssh_basename(const char *path)
basename - parse filename component.
Definition misc.c:977
ssh_key_free
LIBSSH_API void ssh_key_free(ssh_key key)
deallocate a SSH key
Definition pki.c:179
ssh_key_is_private
LIBSSH_API int ssh_key_is_private(const ssh_key k)
Check if the key is a private key.
Definition pki.c:640
ssh_pki_export_privkey_base64_format
LIBSSH_API int ssh_pki_export_privkey_base64_format(const ssh_key privkey, const char *passphrase, ssh_auth_callback auth_fn, void *auth_data, char **b64_key, enum ssh_file_format_e format)
Convert a private key to a base64 encoded key in given format.
Definition pki.c:863
ssh_pki_key_ecdsa_name
LIBSSH_API const char * ssh_pki_key_ecdsa_name(const ssh_key key)
returns the ECDSA key name ("ecdsa-sha2-nistp256" for example)
Definition pki.c:91
ssh_pki_import_privkey_file
LIBSSH_API int ssh_pki_import_privkey_file(const char *filename, const char *passphrase, ssh_auth_callback auth_fn, void *auth_data, ssh_key *pkey)
Import a private key from a file or a PKCS #11 device.
Definition pki.c:976
ssh_pki_export_pubkey_base64
LIBSSH_API int ssh_pki_export_pubkey_base64(const ssh_key key, char **b64_key)
Convert a public key to a base64 encoded key.
Definition pki.c:2208
ssh_pki_export_privkey_base64
LIBSSH_API int ssh_pki_export_privkey_base64(const ssh_key privkey, const char *passphrase, ssh_auth_callback auth_fn, void *auth_data, char **b64_key)
Convert a private key to a pem base64 encoded key, or OpenSSH format for keytype ssh-ed25519.
Definition pki.c:939
ssh_pki_export_privkey_file
LIBSSH_API int ssh_pki_export_privkey_file(const ssh_key privkey, const char *passphrase, ssh_auth_callback auth_fn, void *auth_data, const char *filename)
Export a private key to a pem file on disk, or OpenSSH format for keytype ssh-ed25519.
Definition pki.c:1166
ssh_key_type_from_name
LIBSSH_API enum ssh_keytypes_e ssh_key_type_from_name(const char *name)
Convert a ssh key name to a ssh key type.
Definition pki.c:545
ssh_key_cmp
LIBSSH_API int ssh_key_cmp(const ssh_key k1, const ssh_key k2, enum ssh_keycmp_e what)
Compare keys if they are equal.
Definition pki.c:659
ssh_pki_export_pubkey_file
LIBSSH_API int ssh_pki_export_pubkey_file(const ssh_key key, const char *filename)
Export public key to file.
Definition pki.c:2246
ssh_pki_export_privkey_to_pubkey
LIBSSH_API int ssh_pki_export_privkey_to_pubkey(const ssh_key privkey, ssh_key *pkey)
Create a public key from a private key.
Definition pki.c:2105
ssh_pki_import_privkey_base64
LIBSSH_API int ssh_pki_import_privkey_base64(const char *b64_key, const char *passphrase, ssh_auth_callback auth_fn, void *auth_data, ssh_key *pkey)
import a base64 formatted key from a memory c-string
Definition pki.c:796
ssh_key_type_to_char
LIBSSH_API const char * ssh_key_type_to_char(enum ssh_keytypes_e type)
Convert a key type to a string.
Definition pki.c:261
ssh_pki_copy_cert_to_privkey
LIBSSH_API int ssh_pki_copy_cert_to_privkey(const ssh_key cert_key, ssh_key privkey)
Copy the certificate part of a public key into a private key.
Definition pki.c:2313
ssh_pki_import_cert_base64
LIBSSH_API int ssh_pki_import_cert_base64(const char *b64_cert, enum ssh_keytypes_e type, ssh_key *pkey)
Import a base64 formatted certificate from a memory c-string.
Definition pki.c:1943
ssh_pki_import_cert_file
LIBSSH_API int ssh_pki_import_cert_file(const char *filename, ssh_key *pkey)
Import a certificate from the given filename.
Definition pki.c:1984
ssh_key_is_public
LIBSSH_API int ssh_key_is_public(const ssh_key k)
Check if the key has/is a public key.
Definition pki.c:624
ssh_key_type
LIBSSH_API enum ssh_keytypes_e ssh_key_type(const ssh_key key)
returns the type of a ssh key
Definition pki.c:198
ssh_key_new
LIBSSH_API ssh_key ssh_key_new(void)
creates a new empty SSH key
Definition pki.c:109
ssh_pki_import_pubkey_base64
LIBSSH_API int ssh_pki_import_pubkey_base64(const char *b64_key, enum ssh_keytypes_e type, ssh_key *pkey)
Import a base64 formatted public key from a memory c-string.
Definition pki.c:1635
ssh_pki_export_privkey_file_format
LIBSSH_API int ssh_pki_export_privkey_file_format(const ssh_key privkey, const char *passphrase, ssh_auth_callback auth_fn, void *auth_data, const char *filename, enum ssh_file_format_e format)
Export a private key to a file in format specified in the argument.
Definition pki.c:1081
ssh_pki_generate
LIBSSH_API int ssh_pki_generate(enum ssh_keytypes_e type, int parameter, ssh_key *pkey)
Generates a key pair.
Definition pki.c:2016
ssh_key_dup
LIBSSH_API ssh_key ssh_key_dup(const ssh_key key)
duplicates the key
Definition pki.c:126
ssh_pki_import_pubkey_file
LIBSSH_API int ssh_pki_import_pubkey_file(const char *filename, ssh_key *pkey)
Import a public key from a file or a PKCS #11 device.
Definition pki.c:1798
ssh_event_free
LIBSSH_API void ssh_event_free(ssh_event event)
Free an event context.
Definition poll.c:1145
ssh_event_new
LIBSSH_API ssh_event ssh_event_new(void)
Create a new event context. It could be associated with many ssh_session objects and socket fd which ...
Definition poll.c:802
ssh_event_add_fd
LIBSSH_API int ssh_event_add_fd(ssh_event event, socket_t fd, short events, ssh_event_callback cb, void *userdata)
Add a fd to the event and assign it a callback, when used in blocking mode.
Definition poll.c:861
ssh_event_add_session
LIBSSH_API int ssh_event_add_session(ssh_event event, ssh_session session)
remove the poll handle from session and assign them to an event, when used in blocking mode.
Definition poll.c:931
ssh_event_remove_session
LIBSSH_API int ssh_event_remove_session(ssh_event event, ssh_session session)
Remove a session object from an event context.
Definition poll.c:1076
ssh_event_dopoll
LIBSSH_API int ssh_event_dopoll(ssh_event event, int timeout)
Poll all the sockets and sessions associated through an event object.
Definition poll.c:1009
ssh_event_remove_connector
LIBSSH_API int ssh_event_remove_connector(ssh_event event, ssh_connector connector)
Remove a connector from an event context.
Definition poll.c:1131
ssh_event_add_connector
LIBSSH_API int ssh_event_add_connector(ssh_event event, ssh_connector connector)
Add a connector to the SSH event loop.
Definition poll.c:984
ssh_event_remove_fd
LIBSSH_API int ssh_event_remove_fd(ssh_event event, socket_t fd)
Remove a socket fd from an event context.
Definition poll.c:1029
ssh_scp_read
SSH_DEPRECATED LIBSSH_API int ssh_scp_read(ssh_scp scp, void *buffer, size_t size)
Read from a remote scp file.
Definition scp.c:1011
ssh_scp_write
SSH_DEPRECATED LIBSSH_API int ssh_scp_write(ssh_scp scp, const void *buffer, size_t len)
Write into a remote scp file.
Definition scp.c:670
ssh_scp_close
SSH_DEPRECATED LIBSSH_API int ssh_scp_close(ssh_scp scp)
Close the scp channel.
Definition scp.c:249
ssh_scp_init
SSH_DEPRECATED LIBSSH_API int ssh_scp_init(ssh_scp scp)
Initialize the scp channel.
Definition scp.c:125
ssh_scp_leave_directory
SSH_DEPRECATED LIBSSH_API int ssh_scp_leave_directory(ssh_scp scp)
Leave a directory.
Definition scp.c:423
ssh_scp_request_get_permissions
SSH_DEPRECATED LIBSSH_API int ssh_scp_request_get_permissions(ssh_scp scp)
Get the permissions of the directory or file being pushed from the other party.
Definition scp.c:1101
ssh_scp_request_get_warning
SSH_DEPRECATED LIBSSH_API const char * ssh_scp_request_get_warning(ssh_scp scp)
Get the warning string from a scp handle.
Definition scp.c:1185
ssh_scp_push_file64
SSH_DEPRECATED LIBSSH_API int ssh_scp_push_file64(ssh_scp scp, const char *filename, uint64_t size, int perms)
Initialize the sending of a file to a scp in sink mode, using a 64-bit size.
Definition scp.c:472
ssh_scp_push_file
SSH_DEPRECATED LIBSSH_API int ssh_scp_push_file(ssh_scp scp, const char *filename, size_t size, int perms)
Initialize the sending of a file to a scp in sink mode.
Definition scp.c:575
ssh_scp_request_get_filename
SSH_DEPRECATED LIBSSH_API const char * ssh_scp_request_get_filename(ssh_scp scp)
Get the name of the directory or file being pushed from the other party.
Definition scp.c:1084
ssh_scp_request_get_size
SSH_DEPRECATED LIBSSH_API size_t ssh_scp_request_get_size(ssh_scp scp)
Get the size of the file being pushed from the other party.
Definition scp.c:1120
ssh_scp_new
SSH_DEPRECATED LIBSSH_API ssh_scp ssh_scp_new(ssh_session session, int mode, const char *location)
Create a new scp session.
Definition scp.c:65
ssh_scp_push_directory
SSH_DEPRECATED LIBSSH_API int ssh_scp_push_directory(ssh_scp scp, const char *dirname, int mode)
Create a directory in a scp in sink mode.
Definition scp.c:332
ssh_scp_pull_request
SSH_DEPRECATED LIBSSH_API int ssh_scp_pull_request(ssh_scp scp)
Wait for a scp request (file, directory).
Definition scp.c:809
ssh_scp_free
SSH_DEPRECATED LIBSSH_API void ssh_scp_free(ssh_scp scp)
Free a scp context.
Definition scp.c:296
ssh_scp_deny_request
SSH_DEPRECATED LIBSSH_API int ssh_scp_deny_request(ssh_scp scp, const char *reason)
Deny the transfer of a file or creation of a directory coming from the remote party.
Definition scp.c:923
ssh_scp_accept_request
SSH_DEPRECATED LIBSSH_API int ssh_scp_accept_request(ssh_scp scp)
Accepts transfer of a file or creation of a directory coming from the remote party.
Definition scp.c:969
ssh_scp_request_get_size64
SSH_DEPRECATED LIBSSH_API uint64_t ssh_scp_request_get_size64(ssh_scp scp)
Get the size of the file being pushed from the other party.
Definition scp.c:1135
ssh_get_cipher_out
LIBSSH_API const char * ssh_get_cipher_out(ssh_session session)
get the name of the output cipher for the given session.
Definition session.c:482
ssh_connect
LIBSSH_API int ssh_connect(ssh_session session)
Connect to the ssh server.
Definition client.c:528
ssh_set_fd_except
LIBSSH_API void ssh_set_fd_except(ssh_session session)
Tell the session it has an exception to catch on the file descriptor.
Definition session.c:685
ssh_clean_pubkey_hash
LIBSSH_API void ssh_clean_pubkey_hash(unsigned char **hash)
Deallocate the hash obtained by ssh_get_pubkey_hash.
Definition session.c:1148
ssh_get_disconnect_message
LIBSSH_API const char * ssh_get_disconnect_message(ssh_session session)
Get the disconnect message from the server.
Definition session.c:900
ssh_is_blocking
LIBSSH_API int ssh_is_blocking(ssh_session session)
Return the blocking mode of libssh.
Definition session.c:576
ssh_set_fd_toread
LIBSSH_API void ssh_set_fd_toread(ssh_session session)
Tell the session it has data to read on the file descriptor without blocking.
Definition session.c:659
ssh_disconnect
LIBSSH_API void ssh_disconnect(ssh_session session)
Disconnect from a session (client or server).
Definition client.c:786
ssh_get_serverbanner
LIBSSH_API const char * ssh_get_serverbanner(ssh_session session)
get the server banner
Definition session.c:411
ssh_get_hmac_in
LIBSSH_API const char * ssh_get_hmac_in(ssh_session session)
get the name of the input HMAC algorithm for the given session.
Definition session.c:498
ssh_get_issue_banner
LIBSSH_API char * ssh_get_issue_banner(ssh_session session)
Get the issue banner from the server.
Definition client.c:684
ssh_set_blocking
LIBSSH_API void ssh_set_blocking(ssh_session session, int blocking)
Set the session in blocking/nonblocking mode.
Definition session.c:561
ssh_get_fingerprint_hash
LIBSSH_API char * ssh_get_fingerprint_hash(enum ssh_publickey_hash_type type, unsigned char *hash, size_t len)
Get a hash as a human-readable hex- or base64-string.
Definition dh.c:737
ssh_set_fd_towrite
LIBSSH_API void ssh_set_fd_towrite(ssh_session session)
Tell the session it may write to the file descriptor without blocking.
Definition session.c:672
ssh_is_connected
LIBSSH_API int ssh_is_connected(ssh_session session)
Check if we are connected.
Definition session.c:627
ssh_get_kex_algo
LIBSSH_API const char * ssh_get_kex_algo(ssh_session session)
get the name of the current key exchange algorithm.
Definition session.c:425
ssh_session_export_known_hosts_entry
LIBSSH_API int ssh_session_export_known_hosts_entry(ssh_session session, char **pentry_string)
Export the current session information to a known_hosts string.
Definition knownhosts.c:920
ssh_get_server_publickey
LIBSSH_API int ssh_get_server_publickey(ssh_session session, ssh_key *key)
Get the server public key from a session.
Definition session.c:1165
ssh_dump_knownhost
SSH_DEPRECATED LIBSSH_API char * ssh_dump_knownhost(ssh_session session)
This function is deprecated.
Definition known_hosts.c:446
ssh_send_debug
LIBSSH_API int ssh_send_debug(ssh_session session, const char *message, int always_display)
Send a debug message.
Definition session.c:997
ssh_blocking_flush
LIBSSH_API int ssh_blocking_flush(ssh_session session, int timeout)
Blocking flush of the outgoing buffer.
Definition session.c:602
ssh_get_cipher_in
LIBSSH_API const char * ssh_get_cipher_in(ssh_session session)
get the name of the input cipher for the given session.
Definition session.c:466
ssh_copyright
LIBSSH_API const char * ssh_copyright(void)
Copyright information.
Definition client.c:896
ssh_get_clientbanner
LIBSSH_API const char * ssh_get_clientbanner(ssh_session session)
get the client banner
Definition session.c:396
ssh_is_server_known
SSH_DEPRECATED LIBSSH_API int ssh_is_server_known(ssh_session session)
This function is deprecated.
Definition known_hosts.c:304
ssh_get_publickey_hash
LIBSSH_API int ssh_get_publickey_hash(const ssh_key key, enum ssh_publickey_hash_type type, unsigned char **hash, size_t *hlen)
Allocates a buffer with the hash of the public key.
Definition session.c:1220
ssh_options_set
LIBSSH_API int ssh_options_set(ssh_session session, enum ssh_options_e type, const void *value)
This function can set all possible ssh options.
Definition options.c:645
ssh_options_parse_config
LIBSSH_API int ssh_options_parse_config(ssh_session session, const char *filename)
Parse the ssh config file.
Definition options.c:1815
ssh_get_publickey
SSH_DEPRECATED LIBSSH_API int ssh_get_publickey(ssh_session session, ssh_key *key)
Definition session.c:1187
ssh_get_version
LIBSSH_API int ssh_get_version(ssh_session session)
Get the protocol version of the session.
Definition session.c:925
ssh_set_counters
LIBSSH_API void ssh_set_counters(ssh_session session, ssh_counter scounter, ssh_counter rcounter)
Set the session data counters.
Definition session.c:1053
ssh_select
LIBSSH_API int ssh_select(ssh_channel *channels, ssh_channel *outchannels, socket_t maxfd, fd_set *readfds, struct timeval *timeout)
A wrapper for the select syscall.
Definition connect.c:334
ssh_session_get_known_hosts_entry
LIBSSH_API enum ssh_known_hosts_e ssh_session_get_known_hosts_entry(ssh_session session, struct ssh_knownhosts_entry **pentry)
Get the known_hosts entry for the currently connected session.
Definition knownhosts.c:1163
ssh_print_hash
LIBSSH_API void ssh_print_hash(enum ssh_publickey_hash_type type, unsigned char *hash, size_t len)
Print a hash as a human-readable hex- or base64-string.
Definition dh.c:809
ssh_options_getopt
LIBSSH_API int ssh_options_getopt(ssh_session session, int *argcptr, char **argv)
Parse command line arguments.
Definition options.c:1635
ssh_session_update_known_hosts
LIBSSH_API int ssh_session_update_known_hosts(ssh_session session)
Adds the currently connected server to the user known_hosts file.
Definition knownhosts.c:993
ssh_knownhosts_entry_free
LIBSSH_API void ssh_knownhosts_entry_free(struct ssh_knownhosts_entry *entry)
Free an allocated ssh_knownhosts_entry.
Definition knownhosts.c:155
ssh_request_no_more_sessions
LIBSSH_API int ssh_request_no_more_sessions(ssh_session session)
Most SSH connections will only ever request a single session, but an attacker may abuse a running ssh...
Definition client.c:732
ssh_options_get_port
LIBSSH_API int ssh_options_get_port(ssh_session session, unsigned int *port_target)
This function can get ssh the ssh port. It must only be used on a valid ssh session....
Definition options.c:1413
ssh_known_hosts_parse_line
LIBSSH_API int ssh_known_hosts_parse_line(const char *host, const char *line, struct ssh_knownhosts_entry **entry)
Parse a line from a known_hosts entry into a structure.
Definition knownhosts.c:635
ssh_options_get
LIBSSH_API int ssh_options_get(ssh_session session, enum ssh_options_e type, char **value)
This function can get ssh options, it does not support all options provided for ssh options set,...
Definition options.c:1511
ssh_new
LIBSSH_API ssh_session ssh_new(void)
Create a new ssh session.
Definition session.c:60
ssh_get_hmac_out
LIBSSH_API const char * ssh_get_hmac_out(ssh_session session)
get the name of the output HMAC algorithm for the given session.
Definition session.c:513
ssh_send_ignore
LIBSSH_API int ssh_send_ignore(ssh_session session, const char *data)
Send a message that should be ignored.
Definition session.c:962
ssh_session_set_disconnect_message
LIBSSH_API int ssh_session_set_disconnect_message(ssh_session session, const char *message)
Add disconnect message when ssh_session is disconnected To add a disconnect message to give peer a be...
Definition client.c:750
ssh_get_status
LIBSSH_API int ssh_get_status(ssh_session session)
Get session status.
Definition session.c:842
ssh_get_openssh_version
LIBSSH_API 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.
Definition client.c:711
ssh_session_is_known_server
LIBSSH_API enum ssh_known_hosts_e ssh_session_is_known_server(ssh_session session)
Check if the servers public key for the connected session is known.
Definition knownhosts.c:1288
ssh_silent_disconnect
LIBSSH_API void ssh_silent_disconnect(ssh_session session)
Disconnect impolitely from a remote host by closing the socket.
Definition session.c:544
ssh_free
LIBSSH_API void ssh_free(ssh_session session)
Deallocate a SSH session handle.
Definition session.c:209
ssh_get_poll_flags
LIBSSH_API int ssh_get_poll_flags(ssh_session session)
Get poll flags for an external mainloop.
Definition session.c:880
ssh_options_copy
LIBSSH_API int ssh_options_copy(ssh_session src, ssh_session *dest)
Duplicate the options of a session structure.
Definition options.c:68
ssh_write_knownhost
SSH_DEPRECATED LIBSSH_API int ssh_write_knownhost(ssh_session session)
This function is deprecated.
Definition known_hosts.c:514
ssh_get_pubkey_hash
SSH_DEPRECATED LIBSSH_API int ssh_get_pubkey_hash(ssh_session session, unsigned char **hash)
Definition session.c:1064
ssh_get_fd
LIBSSH_API socket_t ssh_get_fd(ssh_session session)
Get the fd of a connection.
Definition session.c:645
ssh_session_has_known_hosts_entry
LIBSSH_API enum ssh_known_hosts_e ssh_session_has_known_hosts_entry(ssh_session session)
Check if the set hostname and port match an entry in known_hosts.
Definition knownhosts.c:805
ssh_string_from_char
LIBSSH_API ssh_string ssh_string_from_char(const char *what)
Create a ssh string using a C string.
Definition string.c:108
ssh_string_new
LIBSSH_API ssh_string ssh_string_new(size_t size)
Create a new SSH String object.
Definition string.c:56
ssh_string_free_char
LIBSSH_API void ssh_string_free_char(char *s)
Deallocate a char string object.
Definition string.c:209
ssh_init
LIBSSH_API int ssh_init(void)
Initialize global cryptographic data structures.
Definition init.c:156
ssh_finalize
LIBSSH_API int ssh_finalize(void)
Finalize and clean up all libssh and cryptographic data structures.
Definition init.c:241