libssh 0.11.0
The SSH library
Loading...
Searching...
No Matches
libssh.h
1/*
2 * This file is part of the SSH Library
3 *
4 * Copyright (c) 2003-2025 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 <inttypes.h>
53#include <stdarg.h>
54#include <stdbool.h>
55#include <stdint.h>
56
57#ifdef _MSC_VER
58 typedef int mode_t;
59#else /* _MSC_VER */
60 #include <unistd.h>
61 #include <sys/types.h>
62#endif /* _MSC_VER */
63
64#ifdef _WIN32
65 #include <winsock2.h>
66#else /* _WIN32 */
67 #include <sys/select.h> /* for fd_set * */
68 #include <netdb.h>
69#endif /* _WIN32 */
70
71#define SSH_STRINGIFY(s) SSH_TOSTRING(s)
72#define SSH_TOSTRING(s) #s
73
74/* GCC have printf type attribute check. */
75#ifdef __GNUC__
76#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
77#else
78#define PRINTF_ATTRIBUTE(a,b)
79#endif /* __GNUC__ */
80
81#if !defined(SSH_SUPPRESS_DEPRECATED) && defined(__GNUC__)
82#define SSH_DEPRECATED __attribute__ ((deprecated))
83#else
84#define SSH_DEPRECATED
85#endif
86
87#ifdef __cplusplus
88extern "C" {
89#endif
90
91struct ssh_counter_struct {
92 uint64_t in_bytes;
93 uint64_t out_bytes;
94 uint64_t in_packets;
95 uint64_t out_packets;
96};
97typedef struct ssh_counter_struct *ssh_counter;
98
99typedef struct ssh_agent_struct* ssh_agent;
100typedef struct ssh_buffer_struct* ssh_buffer;
101typedef struct ssh_channel_struct* ssh_channel;
102typedef struct ssh_message_struct* ssh_message;
103typedef struct ssh_pcap_file_struct* ssh_pcap_file;
104typedef struct ssh_key_struct* ssh_key;
105typedef struct ssh_scp_struct* ssh_scp;
106typedef struct ssh_session_struct* ssh_session;
107typedef struct ssh_string_struct* ssh_string;
108typedef struct ssh_event_struct* ssh_event;
109typedef struct ssh_connector_struct * ssh_connector;
110typedef struct ssh_pki_ctx_struct *ssh_pki_ctx;
111typedef void* ssh_gssapi_creds;
112
113/* Socket type */
114#ifdef _WIN32
115#ifndef socket_t
116typedef SOCKET socket_t;
117#endif /* socket_t */
118#else /* _WIN32 */
119#ifndef socket_t
120typedef int socket_t;
121#endif
122#endif /* _WIN32 */
123
124#define SSH_INVALID_SOCKET ((socket_t) -1)
125
126/* the offsets of methods */
127enum ssh_kex_types_e {
128 SSH_KEX=0,
129 SSH_HOSTKEYS,
130 SSH_CRYPT_C_S,
131 SSH_CRYPT_S_C,
132 SSH_MAC_C_S,
133 SSH_MAC_S_C,
134 SSH_COMP_C_S,
135 SSH_COMP_S_C,
136 SSH_LANG_C_S,
137 SSH_LANG_S_C
138};
139
140#define SSH_CRYPT 2
141#define SSH_MAC 3
142#define SSH_COMP 4
143#define SSH_LANG 5
144
145enum ssh_auth_e {
146 SSH_AUTH_SUCCESS=0,
147 SSH_AUTH_DENIED,
148 SSH_AUTH_PARTIAL,
149 SSH_AUTH_INFO,
150 SSH_AUTH_AGAIN,
151 SSH_AUTH_ERROR=-1
152};
153
154/* auth flags */
155#define SSH_AUTH_METHOD_UNKNOWN 0x0000u
156#define SSH_AUTH_METHOD_NONE 0x0001u
157#define SSH_AUTH_METHOD_PASSWORD 0x0002u
158#define SSH_AUTH_METHOD_PUBLICKEY 0x0004u
159#define SSH_AUTH_METHOD_HOSTBASED 0x0008u
160#define SSH_AUTH_METHOD_INTERACTIVE 0x0010u
161#define SSH_AUTH_METHOD_GSSAPI_MIC 0x0020u
162
163/* messages */
164enum ssh_requests_e {
165 SSH_REQUEST_AUTH=1,
166 SSH_REQUEST_CHANNEL_OPEN,
167 SSH_REQUEST_CHANNEL,
168 SSH_REQUEST_SERVICE,
169 SSH_REQUEST_GLOBAL
170};
171
172enum ssh_channel_type_e {
173 SSH_CHANNEL_UNKNOWN=0,
174 SSH_CHANNEL_SESSION,
175 SSH_CHANNEL_DIRECT_TCPIP,
176 SSH_CHANNEL_FORWARDED_TCPIP,
177 SSH_CHANNEL_X11,
178 SSH_CHANNEL_AUTH_AGENT
179};
180
181enum ssh_channel_requests_e {
182 SSH_CHANNEL_REQUEST_UNKNOWN=0,
183 SSH_CHANNEL_REQUEST_PTY,
184 SSH_CHANNEL_REQUEST_EXEC,
185 SSH_CHANNEL_REQUEST_SHELL,
186 SSH_CHANNEL_REQUEST_ENV,
187 SSH_CHANNEL_REQUEST_SUBSYSTEM,
188 SSH_CHANNEL_REQUEST_WINDOW_CHANGE,
189 SSH_CHANNEL_REQUEST_X11
190};
191
192enum ssh_global_requests_e {
193 SSH_GLOBAL_REQUEST_UNKNOWN=0,
194 SSH_GLOBAL_REQUEST_TCPIP_FORWARD,
195 SSH_GLOBAL_REQUEST_CANCEL_TCPIP_FORWARD,
196 SSH_GLOBAL_REQUEST_KEEPALIVE,
197 SSH_GLOBAL_REQUEST_NO_MORE_SESSIONS
198};
199
200enum ssh_publickey_state_e {
201 SSH_PUBLICKEY_STATE_ERROR=-1,
202 SSH_PUBLICKEY_STATE_NONE=0,
203 SSH_PUBLICKEY_STATE_VALID=1,
204 SSH_PUBLICKEY_STATE_WRONG=2
205};
206
207/* Status flags */
209#define SSH_CLOSED 0x01
211#define SSH_READ_PENDING 0x02
213#define SSH_CLOSED_ERROR 0x04
215#define SSH_WRITE_PENDING 0x08
216
217enum ssh_server_known_e {
218 SSH_SERVER_ERROR=-1,
219 SSH_SERVER_NOT_KNOWN=0,
220 SSH_SERVER_KNOWN_OK,
221 SSH_SERVER_KNOWN_CHANGED,
222 SSH_SERVER_FOUND_OTHER,
223 SSH_SERVER_FILE_NOT_FOUND
224};
225
226enum ssh_known_hosts_e {
230 SSH_KNOWN_HOSTS_ERROR = -2,
231
236 SSH_KNOWN_HOSTS_NOT_FOUND = -1,
237
242 SSH_KNOWN_HOSTS_UNKNOWN = 0,
243
247 SSH_KNOWN_HOSTS_OK,
248
254 SSH_KNOWN_HOSTS_CHANGED,
255
260 SSH_KNOWN_HOSTS_OTHER,
261};
262
263#ifndef MD5_DIGEST_LEN
264 #define MD5_DIGEST_LEN 16
265#endif
266/* errors */
267
268enum ssh_error_types_e {
269 SSH_NO_ERROR=0,
270 SSH_REQUEST_DENIED,
271 SSH_FATAL,
272 SSH_EINTR
273};
274
275/* some types for keys */
276enum ssh_keytypes_e{
277 SSH_KEYTYPE_UNKNOWN=0,
278 SSH_KEYTYPE_DSS=1, /* deprecated */
279 SSH_KEYTYPE_RSA,
280 SSH_KEYTYPE_RSA1,
281 SSH_KEYTYPE_ECDSA, /* deprecated */
282 SSH_KEYTYPE_ED25519,
283 SSH_KEYTYPE_DSS_CERT01, /* deprecated */
284 SSH_KEYTYPE_RSA_CERT01,
285 SSH_KEYTYPE_ECDSA_P256,
286 SSH_KEYTYPE_ECDSA_P384,
287 SSH_KEYTYPE_ECDSA_P521,
288 SSH_KEYTYPE_ECDSA_P256_CERT01,
289 SSH_KEYTYPE_ECDSA_P384_CERT01,
290 SSH_KEYTYPE_ECDSA_P521_CERT01,
291 SSH_KEYTYPE_ED25519_CERT01,
292 SSH_KEYTYPE_SK_ECDSA,
293 SSH_KEYTYPE_SK_ECDSA_CERT01,
294 SSH_KEYTYPE_SK_ED25519,
295 SSH_KEYTYPE_SK_ED25519_CERT01,
296};
297
298enum ssh_keycmp_e {
299 SSH_KEY_CMP_PUBLIC = 0,
300 SSH_KEY_CMP_PRIVATE = 1,
301 SSH_KEY_CMP_CERTIFICATE = 2,
302};
303
304#define SSH_ADDRSTRLEN 46
305
306struct ssh_knownhosts_entry {
307 char *hostname;
308 char *unparsed;
309 ssh_key publickey;
310 char *comment;
311};
312
313
314/* Error return codes */
315#define SSH_OK 0 /* No error */
316#define SSH_ERROR -1 /* Error of some kind */
317#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
318#define SSH_EOF -127 /* We have already a eof */
319
325
326enum {
342};
344#define SSH_LOG_RARE SSH_LOG_WARNING
345
352
354#define SSH_LOG_NONE 0
356#define SSH_LOG_WARN 1
358#define SSH_LOG_INFO 2
360#define SSH_LOG_DEBUG 3
362#define SSH_LOG_TRACE 4
363
365
366enum ssh_control_master_options_e {
367 SSH_CONTROL_MASTER_NO,
368 SSH_CONTROL_MASTER_AUTO,
369 SSH_CONTROL_MASTER_YES,
370 SSH_CONTROL_MASTER_ASK,
371 SSH_CONTROL_MASTER_AUTOASK
372};
373
374enum ssh_options_e {
375 SSH_OPTIONS_HOST,
376 SSH_OPTIONS_PORT,
377 SSH_OPTIONS_PORT_STR,
378 SSH_OPTIONS_FD,
379 SSH_OPTIONS_USER,
380 SSH_OPTIONS_SSH_DIR,
381 SSH_OPTIONS_IDENTITY,
382 SSH_OPTIONS_ADD_IDENTITY,
383 SSH_OPTIONS_KNOWNHOSTS,
384 SSH_OPTIONS_TIMEOUT,
385 SSH_OPTIONS_TIMEOUT_USEC,
386 SSH_OPTIONS_SSH1,
387 SSH_OPTIONS_SSH2,
388 SSH_OPTIONS_LOG_VERBOSITY,
389 SSH_OPTIONS_LOG_VERBOSITY_STR,
390 SSH_OPTIONS_CIPHERS_C_S,
391 SSH_OPTIONS_CIPHERS_S_C,
392 SSH_OPTIONS_COMPRESSION_C_S,
393 SSH_OPTIONS_COMPRESSION_S_C,
394 SSH_OPTIONS_PROXYCOMMAND,
395 SSH_OPTIONS_BINDADDR,
396 SSH_OPTIONS_STRICTHOSTKEYCHECK,
397 SSH_OPTIONS_COMPRESSION,
398 SSH_OPTIONS_COMPRESSION_LEVEL,
399 SSH_OPTIONS_KEY_EXCHANGE,
400 SSH_OPTIONS_HOSTKEYS,
401 SSH_OPTIONS_GSSAPI_SERVER_IDENTITY,
402 SSH_OPTIONS_GSSAPI_CLIENT_IDENTITY,
403 SSH_OPTIONS_GSSAPI_DELEGATE_CREDENTIALS,
404 SSH_OPTIONS_HMAC_C_S,
405 SSH_OPTIONS_HMAC_S_C,
406 SSH_OPTIONS_PASSWORD_AUTH,
407 SSH_OPTIONS_PUBKEY_AUTH,
408 SSH_OPTIONS_KBDINT_AUTH,
409 SSH_OPTIONS_GSSAPI_AUTH,
410 SSH_OPTIONS_GLOBAL_KNOWNHOSTS,
411 SSH_OPTIONS_NODELAY,
412 SSH_OPTIONS_PUBLICKEY_ACCEPTED_TYPES,
413 SSH_OPTIONS_PROCESS_CONFIG,
414 SSH_OPTIONS_REKEY_DATA,
415 SSH_OPTIONS_REKEY_TIME,
416 SSH_OPTIONS_RSA_MIN_SIZE,
417 SSH_OPTIONS_IDENTITY_AGENT,
418 SSH_OPTIONS_IDENTITIES_ONLY,
419 SSH_OPTIONS_CONTROL_MASTER,
420 SSH_OPTIONS_CONTROL_PATH,
421 SSH_OPTIONS_CERTIFICATE,
422 SSH_OPTIONS_PROXYJUMP,
423 SSH_OPTIONS_PROXYJUMP_CB_LIST_APPEND,
424 SSH_OPTIONS_PKI_CONTEXT,
425};
426
427enum {
429 SSH_SCP_WRITE,
431 SSH_SCP_READ,
432 SSH_SCP_RECURSIVE=0x10
433};
434
435enum ssh_scp_request_types {
437 SSH_SCP_REQUEST_NEWDIR=1,
439 SSH_SCP_REQUEST_NEWFILE,
441 SSH_SCP_REQUEST_EOF,
443 SSH_SCP_REQUEST_ENDDIR,
445 SSH_SCP_REQUEST_WARNING
446};
447
448enum ssh_connector_flags_e {
450 SSH_CONNECTOR_STDOUT = 1,
451 SSH_CONNECTOR_STDINOUT = 1,
453 SSH_CONNECTOR_STDERR = 2,
455 SSH_CONNECTOR_BOTH = 3
456};
457
458LIBSSH_API int ssh_blocking_flush(ssh_session session, int timeout);
459LIBSSH_API ssh_channel ssh_channel_accept_x11(ssh_channel channel, int timeout_ms);
460LIBSSH_API int ssh_channel_change_pty_size(ssh_channel channel,int cols,int rows);
461LIBSSH_API int ssh_channel_close(ssh_channel channel);
462#define SSH_CHANNEL_FREE(x) \
463 do { \
464 if ((x) != NULL) { \
465 ssh_channel_free(x); \
466 (x) = NULL; \
467 } \
468 } while (0)
469LIBSSH_API void ssh_channel_free(ssh_channel channel);
470LIBSSH_API int ssh_channel_get_exit_state(ssh_channel channel,
471 uint32_t *pexit_code,
472 char **pexit_signal,
473 int *pcore_dumped);
474SSH_DEPRECATED LIBSSH_API int ssh_channel_get_exit_status(ssh_channel channel);
475LIBSSH_API ssh_session ssh_channel_get_session(ssh_channel channel);
476LIBSSH_API int ssh_channel_is_closed(ssh_channel channel);
477LIBSSH_API int ssh_channel_is_eof(ssh_channel channel);
478LIBSSH_API int ssh_channel_is_open(ssh_channel channel);
479LIBSSH_API ssh_channel ssh_channel_new(ssh_session session);
480LIBSSH_API int ssh_channel_open_auth_agent(ssh_channel channel);
481LIBSSH_API int ssh_channel_open_forward(ssh_channel channel, const char *remotehost,
482 int remoteport, const char *sourcehost, int localport);
483LIBSSH_API int ssh_channel_open_forward_unix(ssh_channel channel, const char *remotepath,
484 const char *sourcehost, int localport);
485LIBSSH_API int ssh_channel_open_session(ssh_channel channel);
486LIBSSH_API int ssh_channel_open_x11(ssh_channel channel, const char *orig_addr, int orig_port);
487LIBSSH_API int ssh_channel_poll(ssh_channel channel, int is_stderr);
488LIBSSH_API int ssh_channel_poll_timeout(ssh_channel channel, int timeout, int is_stderr);
489LIBSSH_API int ssh_channel_read(ssh_channel channel, void *dest, uint32_t count, int is_stderr);
490LIBSSH_API int ssh_channel_read_timeout(ssh_channel channel, void *dest, uint32_t count, int is_stderr, int timeout_ms);
491LIBSSH_API int ssh_channel_read_nonblocking(ssh_channel channel, void *dest, uint32_t count,
492 int is_stderr);
493LIBSSH_API int ssh_channel_request_env(ssh_channel channel, const char *name, const char *value);
494LIBSSH_API int ssh_channel_request_exec(ssh_channel channel, const char *cmd);
495LIBSSH_API int ssh_channel_request_pty(ssh_channel channel);
496LIBSSH_API int ssh_channel_request_pty_size(ssh_channel channel, const char *term,
497 int cols, int rows);
498LIBSSH_API int ssh_channel_request_pty_size_modes(ssh_channel channel, const char *term,
499 int cols, int rows, const unsigned char* modes, size_t modes_len);
500LIBSSH_API int ssh_channel_request_shell(ssh_channel channel);
501LIBSSH_API int ssh_channel_request_send_signal(ssh_channel channel, const char *signum);
502LIBSSH_API int ssh_channel_request_send_break(ssh_channel channel, uint32_t length);
503LIBSSH_API int ssh_channel_request_sftp(ssh_channel channel);
504LIBSSH_API int ssh_channel_request_subsystem(ssh_channel channel, const char *subsystem);
505LIBSSH_API int ssh_channel_request_x11(ssh_channel channel, int single_connection, const char *protocol,
506 const char *cookie, int screen_number);
507LIBSSH_API int ssh_channel_request_auth_agent(ssh_channel channel);
508LIBSSH_API int ssh_channel_send_eof(ssh_channel channel);
509LIBSSH_API void ssh_channel_set_blocking(ssh_channel channel, int blocking);
510LIBSSH_API void ssh_channel_set_counter(ssh_channel channel,
511 ssh_counter counter);
512LIBSSH_API int ssh_channel_write(ssh_channel channel, const void *data, uint32_t len);
513LIBSSH_API int ssh_channel_write_stderr(ssh_channel channel,
514 const void *data,
515 uint32_t len);
516LIBSSH_API uint32_t ssh_channel_window_size(ssh_channel channel);
517
518LIBSSH_API char *ssh_basename (const char *path);
519LIBSSH_API void ssh_clean_pubkey_hash(unsigned char **hash);
520LIBSSH_API int ssh_connect(ssh_session session);
521
522LIBSSH_API ssh_connector ssh_connector_new(ssh_session session);
523LIBSSH_API void ssh_connector_free(ssh_connector connector);
524LIBSSH_API int ssh_connector_set_in_channel(ssh_connector connector,
525 ssh_channel channel,
526 enum ssh_connector_flags_e flags);
527LIBSSH_API int ssh_connector_set_out_channel(ssh_connector connector,
528 ssh_channel channel,
529 enum ssh_connector_flags_e flags);
530LIBSSH_API void ssh_connector_set_in_fd(ssh_connector connector, socket_t fd);
531LIBSSH_API void ssh_connector_set_out_fd(ssh_connector connector, socket_t fd);
532
533LIBSSH_API const char *ssh_copyright(void);
534LIBSSH_API void ssh_disconnect(ssh_session session);
535LIBSSH_API char *ssh_dirname (const char *path);
536LIBSSH_API int ssh_finalize(void);
537
538/* REVERSE PORT FORWARDING */
539LIBSSH_API ssh_channel ssh_channel_open_forward_port(ssh_session session,
540 int timeout_ms,
541 int *destination_port,
542 char **originator,
543 int *originator_port);
544SSH_DEPRECATED LIBSSH_API ssh_channel ssh_channel_accept_forward(ssh_session session,
545 int timeout_ms,
546 int *destination_port);
547LIBSSH_API int ssh_channel_cancel_forward(ssh_session session,
548 const char *address,
549 int port);
550LIBSSH_API int ssh_channel_listen_forward(ssh_session session,
551 const char *address,
552 int port,
553 int *bound_port);
554
555LIBSSH_API void ssh_free(ssh_session session);
556LIBSSH_API const char *ssh_get_disconnect_message(ssh_session session);
557LIBSSH_API const char *ssh_get_error(void *error);
558LIBSSH_API int ssh_get_error_code(void *error);
559LIBSSH_API socket_t ssh_get_fd(ssh_session session);
560LIBSSH_API char *ssh_get_hexa(const unsigned char *what, size_t len);
561LIBSSH_API char *ssh_get_issue_banner(ssh_session session);
562LIBSSH_API int ssh_get_openssh_version(ssh_session session);
563LIBSSH_API int ssh_request_no_more_sessions(ssh_session session);
564
565LIBSSH_API int ssh_get_server_publickey(ssh_session session, ssh_key *key);
566
567enum ssh_publickey_hash_type {
568 SSH_PUBLICKEY_HASH_SHA1,
569 SSH_PUBLICKEY_HASH_MD5,
570 SSH_PUBLICKEY_HASH_SHA256
571};
572LIBSSH_API int ssh_get_publickey_hash(const ssh_key key,
573 enum ssh_publickey_hash_type type,
574 unsigned char **hash,
575 size_t *hlen);
576
577/* DEPRECATED FUNCTIONS */
578SSH_DEPRECATED LIBSSH_API int ssh_get_pubkey_hash(ssh_session session, unsigned char **hash);
579SSH_DEPRECATED LIBSSH_API ssh_channel ssh_forward_accept(ssh_session session, int timeout_ms);
580SSH_DEPRECATED LIBSSH_API int ssh_forward_cancel(ssh_session session, const char *address, int port);
581SSH_DEPRECATED LIBSSH_API int ssh_forward_listen(ssh_session session, const char *address, int port, int *bound_port);
582SSH_DEPRECATED LIBSSH_API int ssh_get_publickey(ssh_session session, ssh_key *key);
583SSH_DEPRECATED LIBSSH_API int ssh_write_knownhost(ssh_session session);
584SSH_DEPRECATED LIBSSH_API char *ssh_dump_knownhost(ssh_session session);
585SSH_DEPRECATED LIBSSH_API int ssh_is_server_known(ssh_session session);
586SSH_DEPRECATED LIBSSH_API void ssh_print_hexa(const char *descr, const unsigned char *what, size_t len);
587SSH_DEPRECATED LIBSSH_API int ssh_channel_select(ssh_channel *readchans, ssh_channel *writechans, ssh_channel *exceptchans, struct
588 timeval * timeout);
589
590SSH_DEPRECATED LIBSSH_API int ssh_scp_accept_request(ssh_scp scp);
591SSH_DEPRECATED LIBSSH_API int ssh_scp_close(ssh_scp scp);
592SSH_DEPRECATED LIBSSH_API int ssh_scp_deny_request(ssh_scp scp, const char *reason);
593SSH_DEPRECATED LIBSSH_API void ssh_scp_free(ssh_scp scp);
594SSH_DEPRECATED LIBSSH_API int ssh_scp_init(ssh_scp scp);
595SSH_DEPRECATED LIBSSH_API int ssh_scp_leave_directory(ssh_scp scp);
596SSH_DEPRECATED LIBSSH_API ssh_scp ssh_scp_new(ssh_session session, int mode, const char *location);
597SSH_DEPRECATED LIBSSH_API int ssh_scp_pull_request(ssh_scp scp);
598SSH_DEPRECATED LIBSSH_API int ssh_scp_push_directory(ssh_scp scp, const char *dirname, int mode);
599SSH_DEPRECATED LIBSSH_API int ssh_scp_push_file(ssh_scp scp, const char *filename, size_t size, int perms);
600SSH_DEPRECATED LIBSSH_API int ssh_scp_push_file64(ssh_scp scp, const char *filename, uint64_t size, int perms);
601SSH_DEPRECATED LIBSSH_API int ssh_scp_read(ssh_scp scp, void *buffer, size_t size);
602SSH_DEPRECATED LIBSSH_API const char *ssh_scp_request_get_filename(ssh_scp scp);
603SSH_DEPRECATED LIBSSH_API int ssh_scp_request_get_permissions(ssh_scp scp);
604SSH_DEPRECATED LIBSSH_API size_t ssh_scp_request_get_size(ssh_scp scp);
605SSH_DEPRECATED LIBSSH_API uint64_t ssh_scp_request_get_size64(ssh_scp scp);
606SSH_DEPRECATED LIBSSH_API const char *ssh_scp_request_get_warning(ssh_scp scp);
607SSH_DEPRECATED LIBSSH_API int ssh_scp_write(ssh_scp scp, const void *buffer, size_t len);
608
609
610LIBSSH_API int ssh_get_random(void *where,int len,int strong);
611LIBSSH_API int ssh_get_version(ssh_session session);
612LIBSSH_API int ssh_get_status(ssh_session session);
613LIBSSH_API int ssh_get_poll_flags(ssh_session session);
614LIBSSH_API int ssh_init(void);
615LIBSSH_API int ssh_is_blocking(ssh_session session);
616LIBSSH_API int ssh_is_connected(ssh_session session);
617
618/* KNOWN HOSTS */
619LIBSSH_API void ssh_knownhosts_entry_free(struct ssh_knownhosts_entry *entry);
620#define SSH_KNOWNHOSTS_ENTRY_FREE(e) do { \
621 if ((e) != NULL) { \
622 ssh_knownhosts_entry_free(e); \
623 e = NULL; \
624 } \
625} while(0)
626
627LIBSSH_API int ssh_known_hosts_parse_line(const char *host,
628 const char *line,
629 struct ssh_knownhosts_entry **entry);
630LIBSSH_API enum ssh_known_hosts_e ssh_session_has_known_hosts_entry(ssh_session session);
631
632LIBSSH_API int ssh_session_export_known_hosts_entry(ssh_session session,
633 char **pentry_string);
634LIBSSH_API int ssh_session_update_known_hosts(ssh_session session);
635
636LIBSSH_API enum ssh_known_hosts_e ssh_session_get_known_hosts_entry(ssh_session session,
637 struct ssh_knownhosts_entry **pentry);
638LIBSSH_API enum ssh_known_hosts_e ssh_session_is_known_server(ssh_session session);
639
640/* LOGGING */
641LIBSSH_API int ssh_set_log_level(int level);
642LIBSSH_API int ssh_get_log_level(void);
643LIBSSH_API void *ssh_get_log_userdata(void);
644LIBSSH_API int ssh_set_log_userdata(void *data);
645LIBSSH_API void ssh_vlog(int verbosity,
646 const char *function,
647 const char *format,
648 va_list *va) PRINTF_ATTRIBUTE(3, 0);
649LIBSSH_API void _ssh_log(int verbosity,
650 const char *function,
651 const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
652
653/* legacy */
654SSH_DEPRECATED LIBSSH_API void ssh_log(ssh_session session,
655 int prioriry,
656 const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
657
658LIBSSH_API ssh_channel ssh_message_channel_request_open_reply_accept(ssh_message msg);
659LIBSSH_API int ssh_message_channel_request_open_reply_accept_channel(ssh_message msg, ssh_channel chan);
660LIBSSH_API int ssh_message_channel_request_reply_success(ssh_message msg);
661#define SSH_MESSAGE_FREE(x) \
662 do { if ((x) != NULL) { ssh_message_free(x); (x) = NULL; } } while(0)
663LIBSSH_API void ssh_message_free(ssh_message msg);
664LIBSSH_API ssh_message ssh_message_get(ssh_session session);
665LIBSSH_API int ssh_message_subtype(ssh_message msg);
666LIBSSH_API int ssh_message_type(ssh_message msg);
667LIBSSH_API int ssh_mkdir (const char *pathname, mode_t mode);
668LIBSSH_API ssh_session ssh_new(void);
669
670LIBSSH_API int ssh_options_copy(ssh_session src, ssh_session *dest);
671LIBSSH_API int ssh_options_getopt(ssh_session session, int *argcptr, char **argv);
672LIBSSH_API int ssh_options_parse_config(ssh_session session, const char *filename);
673LIBSSH_API int ssh_options_set(ssh_session session, enum ssh_options_e type,
674 const void *value);
675LIBSSH_API int ssh_options_get(ssh_session session, enum ssh_options_e type,
676 char **value);
677LIBSSH_API int ssh_options_get_port(ssh_session session, unsigned int * port_target);
678LIBSSH_API int ssh_pcap_file_close(ssh_pcap_file pcap);
679LIBSSH_API void ssh_pcap_file_free(ssh_pcap_file pcap);
680LIBSSH_API ssh_pcap_file ssh_pcap_file_new(void);
681LIBSSH_API int ssh_pcap_file_open(ssh_pcap_file pcap, const char *filename);
682
688
702typedef int (*ssh_auth_callback) (const char *prompt, char *buf, size_t len,
703 int echo, int verify, void *userdata);
704
706
707enum ssh_file_format_e {
708 SSH_FILE_FORMAT_DEFAULT = 0,
709 SSH_FILE_FORMAT_OPENSSH,
710 SSH_FILE_FORMAT_PEM,
711};
712
713LIBSSH_API ssh_key ssh_key_new(void);
714#define SSH_KEY_FREE(x) \
715 do { if ((x) != NULL) { ssh_key_free(x); x = NULL; } } while(0)
716LIBSSH_API void ssh_key_free (ssh_key key);
717LIBSSH_API enum ssh_keytypes_e ssh_key_type(const ssh_key key);
718LIBSSH_API const char *ssh_key_type_to_char(enum ssh_keytypes_e type);
719LIBSSH_API enum ssh_keytypes_e ssh_key_type_from_name(const char *name);
720LIBSSH_API int ssh_key_is_public(const ssh_key k);
721LIBSSH_API int ssh_key_is_private(const ssh_key k);
722LIBSSH_API int ssh_key_cmp(const ssh_key k1,
723 const ssh_key k2,
724 enum ssh_keycmp_e what);
725LIBSSH_API ssh_key ssh_key_dup(const ssh_key key);
726LIBSSH_API uint32_t ssh_key_get_sk_flags(const ssh_key key);
727LIBSSH_API ssh_string ssh_key_get_sk_application(const ssh_key key);
728LIBSSH_API ssh_string ssh_key_get_sk_user_id(const ssh_key key);
729
730SSH_DEPRECATED LIBSSH_API int
731ssh_pki_generate(enum ssh_keytypes_e type, int parameter, ssh_key *pkey);
732
733LIBSSH_API int ssh_pki_generate_key(enum ssh_keytypes_e type,
734 ssh_pki_ctx pki_context,
735 ssh_key *pkey);
736
737LIBSSH_API int ssh_pki_import_privkey_base64(const char *b64_key,
738 const char *passphrase,
739 ssh_auth_callback auth_fn,
740 void *auth_data,
741 ssh_key *pkey);
742LIBSSH_API int ssh_pki_export_privkey_base64(const ssh_key privkey,
743 const char *passphrase,
744 ssh_auth_callback auth_fn,
745 void *auth_data,
746 char **b64_key);
747LIBSSH_API int
748ssh_pki_export_privkey_base64_format(const ssh_key privkey,
749 const char *passphrase,
750 ssh_auth_callback auth_fn,
751 void *auth_data,
752 char **b64_key,
753 enum ssh_file_format_e format);
754LIBSSH_API int ssh_pki_import_privkey_file(const char *filename,
755 const char *passphrase,
756 ssh_auth_callback auth_fn,
757 void *auth_data,
758 ssh_key *pkey);
759LIBSSH_API int ssh_pki_export_privkey_file(const ssh_key privkey,
760 const char *passphrase,
761 ssh_auth_callback auth_fn,
762 void *auth_data,
763 const char *filename);
764LIBSSH_API int
765ssh_pki_export_privkey_file_format(const ssh_key privkey,
766 const char *passphrase,
767 ssh_auth_callback auth_fn,
768 void *auth_data,
769 const char *filename,
770 enum ssh_file_format_e format);
771
772LIBSSH_API int ssh_pki_copy_cert_to_privkey(const ssh_key cert_key,
773 ssh_key privkey);
774
775LIBSSH_API int ssh_pki_import_pubkey_base64(const char *b64_key,
776 enum ssh_keytypes_e type,
777 ssh_key *pkey);
778LIBSSH_API int ssh_pki_import_pubkey_file(const char *filename,
779 ssh_key *pkey);
780
781LIBSSH_API int ssh_pki_import_cert_base64(const char *b64_cert,
782 enum ssh_keytypes_e type,
783 ssh_key *pkey);
784LIBSSH_API int ssh_pki_import_cert_file(const char *filename,
785 ssh_key *pkey);
786
787LIBSSH_API int ssh_pki_export_privkey_to_pubkey(const ssh_key privkey,
788 ssh_key *pkey);
789LIBSSH_API int ssh_pki_export_pubkey_base64(const ssh_key key,
790 char **b64_key);
791LIBSSH_API int ssh_pki_export_pubkey_file(const ssh_key key,
792 const char *filename);
793
794LIBSSH_API const char *ssh_pki_key_ecdsa_name(const ssh_key key);
795
796LIBSSH_API char *ssh_get_fingerprint_hash(enum ssh_publickey_hash_type type,
797 unsigned char *hash,
798 size_t len);
799LIBSSH_API void ssh_print_hash(enum ssh_publickey_hash_type type, unsigned char *hash, size_t len);
800LIBSSH_API int ssh_send_ignore (ssh_session session, const char *data);
801LIBSSH_API int ssh_send_debug (ssh_session session, const char *message, int always_display);
802LIBSSH_API void ssh_gssapi_set_creds(ssh_session session, const ssh_gssapi_creds creds);
803LIBSSH_API int ssh_select(ssh_channel *channels, ssh_channel *outchannels, socket_t maxfd,
804 fd_set *readfds, struct timeval *timeout);
805LIBSSH_API int ssh_service_request(ssh_session session, const char *service);
806LIBSSH_API int ssh_set_agent_channel(ssh_session session, ssh_channel channel);
807LIBSSH_API int ssh_set_agent_socket(ssh_session session, socket_t fd);
808LIBSSH_API void ssh_set_blocking(ssh_session session, int blocking);
809LIBSSH_API void ssh_set_counters(ssh_session session, ssh_counter scounter,
810 ssh_counter rcounter);
811LIBSSH_API void ssh_set_fd_except(ssh_session session);
812LIBSSH_API void ssh_set_fd_toread(ssh_session session);
813LIBSSH_API void ssh_set_fd_towrite(ssh_session session);
814LIBSSH_API void ssh_silent_disconnect(ssh_session session);
815LIBSSH_API int ssh_set_pcap_file(ssh_session session, ssh_pcap_file pcapfile);
816
817/* USERAUTH */
818LIBSSH_API int ssh_userauth_none(ssh_session session, const char *username);
819LIBSSH_API int ssh_userauth_list(ssh_session session, const char *username);
820LIBSSH_API int ssh_userauth_try_publickey(ssh_session session,
821 const char *username,
822 const ssh_key pubkey);
823LIBSSH_API int ssh_userauth_publickey(ssh_session session,
824 const char *username,
825 const ssh_key privkey);
826LIBSSH_API int ssh_userauth_agent(ssh_session session,
827 const char *username);
828LIBSSH_API int ssh_userauth_publickey_auto_get_current_identity(ssh_session session,
829 char** value);
830LIBSSH_API int ssh_userauth_publickey_auto(ssh_session session,
831 const char *username,
832 const char *passphrase);
833LIBSSH_API int ssh_userauth_password(ssh_session session,
834 const char *username,
835 const char *password);
836
837LIBSSH_API int ssh_userauth_kbdint(ssh_session session, const char *user, const char *submethods);
838LIBSSH_API const char *ssh_userauth_kbdint_getinstruction(ssh_session session);
839LIBSSH_API const char *ssh_userauth_kbdint_getname(ssh_session session);
840LIBSSH_API int ssh_userauth_kbdint_getnprompts(ssh_session session);
841LIBSSH_API const char *ssh_userauth_kbdint_getprompt(ssh_session session, unsigned int i, char *echo);
842LIBSSH_API int ssh_userauth_kbdint_getnanswers(ssh_session session);
843LIBSSH_API const char *ssh_userauth_kbdint_getanswer(ssh_session session, unsigned int i);
844LIBSSH_API int ssh_userauth_kbdint_setanswer(ssh_session session, unsigned int i,
845 const char *answer);
846LIBSSH_API int ssh_userauth_gssapi(ssh_session session);
847LIBSSH_API const char *ssh_version(int req_version);
848
849LIBSSH_API void ssh_string_burn(ssh_string str);
850LIBSSH_API ssh_string ssh_string_copy(ssh_string str);
851LIBSSH_API void *ssh_string_data(ssh_string str);
852LIBSSH_API int ssh_string_fill(ssh_string str, const void *data, size_t len);
853#define SSH_STRING_FREE(x) \
854 do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
855LIBSSH_API void ssh_string_free(ssh_string str);
856LIBSSH_API ssh_string ssh_string_from_char(const char *what);
857LIBSSH_API ssh_string ssh_string_from_data(const void *data, size_t len);
858LIBSSH_API size_t ssh_string_len(ssh_string str);
859LIBSSH_API ssh_string ssh_string_new(size_t size);
860LIBSSH_API const char *ssh_string_get_char(ssh_string str);
861LIBSSH_API char *ssh_string_to_char(ssh_string str);
862#define SSH_STRING_FREE_CHAR(x) \
863 do { if ((x) != NULL) { ssh_string_free_char(x); x = NULL; } } while(0)
864LIBSSH_API void ssh_string_free_char(char *s);
865LIBSSH_API int ssh_string_cmp(ssh_string s1, ssh_string s2);
866
867LIBSSH_API int ssh_getpass(const char *prompt, char *buf, size_t len, int echo,
868 int verify);
869
870
871typedef int (*ssh_event_callback)(socket_t fd, int revents, void *userdata);
872
873LIBSSH_API ssh_event ssh_event_new(void);
874LIBSSH_API int ssh_event_add_fd(ssh_event event, socket_t fd, short events,
875 ssh_event_callback cb, void *userdata);
876LIBSSH_API int ssh_event_add_session(ssh_event event, ssh_session session);
877LIBSSH_API int ssh_event_add_connector(ssh_event event, ssh_connector connector);
878LIBSSH_API int ssh_event_dopoll(ssh_event event, int timeout);
879LIBSSH_API int ssh_event_remove_fd(ssh_event event, socket_t fd);
880LIBSSH_API int ssh_event_remove_session(ssh_event event, ssh_session session);
881LIBSSH_API int ssh_event_remove_connector(ssh_event event, ssh_connector connector);
882LIBSSH_API void ssh_event_free(ssh_event event);
883LIBSSH_API const char* ssh_get_clientbanner(ssh_session session);
884LIBSSH_API const char* ssh_get_serverbanner(ssh_session session);
885LIBSSH_API const char* ssh_get_kex_algo(ssh_session session);
886LIBSSH_API const char* ssh_get_cipher_in(ssh_session session);
887LIBSSH_API const char* ssh_get_cipher_out(ssh_session session);
888LIBSSH_API const char* ssh_get_hmac_in(ssh_session session);
889LIBSSH_API const char* ssh_get_hmac_out(ssh_session session);
890LIBSSH_API const char *ssh_get_supported_methods(enum ssh_kex_types_e type);
891
892LIBSSH_API ssh_buffer ssh_buffer_new(void);
893LIBSSH_API void ssh_buffer_free(ssh_buffer buffer);
894#define SSH_BUFFER_FREE(x) \
895 do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
896LIBSSH_API int ssh_buffer_reinit(ssh_buffer buffer);
897LIBSSH_API int ssh_buffer_add_data(ssh_buffer buffer, const void *data, uint32_t len);
898LIBSSH_API uint32_t ssh_buffer_get_data(ssh_buffer buffer, void *data, uint32_t requestedlen);
899LIBSSH_API void *ssh_buffer_get(ssh_buffer buffer);
900LIBSSH_API uint32_t ssh_buffer_get_len(ssh_buffer buffer);
901LIBSSH_API int ssh_session_set_disconnect_message(ssh_session session, const char *message);
902
903/* SSHSIG hashes data independently from the key used, so we use a new enum
904 to avoid confusion. See
905 https://gitlab.com/jas/ietf-sshsig-format/-/blob/cc70a225cbd695d5a6f20aaebdb4b92b0818e43a/ietf-sshsig-format.md#L137
906 */
907enum sshsig_digest_e {
908 SSHSIG_DIGEST_SHA2_256 = 0,
909 SSHSIG_DIGEST_SHA2_512 = 1,
910};
911
912LIBSSH_API int sshsig_sign(const void *data,
913 size_t data_length,
914 ssh_key privkey,
915 ssh_pki_ctx pki_context,
916 const char *sig_namespace,
917 enum sshsig_digest_e hash_alg,
918 char **signature);
919LIBSSH_API int sshsig_verify(const void *data,
920 size_t data_length,
921 const char *signature,
922 const char *sig_namespace,
923 ssh_key *sign_key);
924
925/* PKI context API */
926
927enum ssh_pki_options_e {
928 SSH_PKI_OPTION_RSA_KEY_SIZE,
929
930 /* Security Key options */
931 SSH_PKI_OPTION_SK_APPLICATION,
932 SSH_PKI_OPTION_SK_FLAGS,
933 SSH_PKI_OPTION_SK_USER_ID,
934 SSH_PKI_OPTION_SK_CHALLENGE,
935 SSH_PKI_OPTION_SK_CALLBACKS,
936};
937
938/* FIDO2/U2F Operation Flags */
939
941#ifndef SSH_SK_USER_PRESENCE_REQD
942#define SSH_SK_USER_PRESENCE_REQD 0x01
943#endif
944
946#ifndef SSH_SK_USER_VERIFICATION_REQD
947#define SSH_SK_USER_VERIFICATION_REQD 0x04
948#endif
949
952#ifndef SSH_SK_FORCE_OPERATION
953#define SSH_SK_FORCE_OPERATION 0x10
954#endif
955
957#ifndef SSH_SK_RESIDENT_KEY
958#define SSH_SK_RESIDENT_KEY 0x20
959#endif
960
961LIBSSH_API ssh_pki_ctx ssh_pki_ctx_new(void);
962
963LIBSSH_API int ssh_pki_ctx_options_set(ssh_pki_ctx context,
964 enum ssh_pki_options_e option,
965 const void *value);
966
967LIBSSH_API int ssh_pki_ctx_set_sk_pin_callback(ssh_pki_ctx context,
968 ssh_auth_callback pin_callback,
969 void *userdata);
970
971#define SSH_SK_OPTION_NAME_DEVICE_PATH "device"
972#define SSH_SK_OPTION_NAME_USER_ID "user"
973
974LIBSSH_API int ssh_pki_ctx_sk_callbacks_option_set(ssh_pki_ctx context,
975 const char *name,
976 const char *value,
977 bool required);
978
979LIBSSH_API int ssh_pki_ctx_sk_callbacks_options_clear(ssh_pki_ctx context);
980
981LIBSSH_API int
983 ssh_buffer *attestation_buffer);
984
985LIBSSH_API void ssh_pki_ctx_free(ssh_pki_ctx context);
986
987#define SSH_PKI_CTX_FREE(x) \
988 do { \
989 if ((x) != NULL) { \
990 ssh_pki_ctx_free(x); \
991 x = NULL; \
992 } \
993 } while (0)
994
995/* Security key resident keys API */
996
997LIBSSH_API int
998ssh_sk_resident_keys_load(const struct ssh_pki_ctx_struct *pki_context,
999 ssh_key **resident_keys_result,
1000 size_t *num_keys_found_result);
1001
1002#ifndef LIBSSH_LEGACY_0_4
1003#include "libssh/legacy.h"
1004#endif
1005
1006#ifdef __cplusplus
1007}
1008#endif
1009#endif /* _LIBSSH_H */
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:2275
LIBSSH_API int ssh_userauth_gssapi(ssh_session session)
Try to authenticate through the "gssapi-with-mic" method.
Definition auth.c:2402
LIBSSH_API int ssh_userauth_list(ssh_session session, const char *username)
Get available authentication methods from the server.
Definition auth.c:380
LIBSSH_API int ssh_userauth_kbdint_getnanswers(ssh_session session)
Get the number of answers the client has given.
Definition auth.c:2303
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:702
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:2321
LIBSSH_API int ssh_userauth_password(ssh_session session, const char *username, const char *password)
Try to authenticate by password.
Definition auth.c:1717
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:1373
LIBSSH_API int ssh_userauth_none(ssh_session session, const char *username)
Try to authenticate through the "none" method.
Definition auth.c:410
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:596
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:178
LIBSSH_API const char * ssh_userauth_kbdint_getname(ssh_session session)
Get the "name" of the message block.
Definition auth.c:2214
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:2147
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:2354
LIBSSH_API int ssh_userauth_agent(ssh_session session, const char *username)
Try to do public key authentication with ssh agent.
Definition auth.c:1011
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:1310
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:201
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:725
LIBSSH_API int ssh_userauth_kbdint_getnprompts(ssh_session session)
Get the number of prompts (questions) the server has given.
Definition auth.c:2191
LIBSSH_API const char * ssh_userauth_kbdint_getinstruction(ssh_session session)
Get the "instruction" of the message block.
Definition auth.c:2238
LIBSSH_API ssh_buffer ssh_buffer_new(void)
Create a new SSH buffer.
Definition buffer.c:120
LIBSSH_API int ssh_channel_request_subsystem(ssh_channel channel, const char *subsystem)
Request a subsystem (for example "sftp").
Definition channels.c:2170
LIBSSH_API int ssh_channel_send_eof(ssh_channel channel)
Send an end of file on the channel.
Definition channels.c:1383
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:3648
LIBSSH_API int ssh_channel_poll(ssh_channel channel, int is_stderr)
Polls a channel for data to read.
Definition channels.c:3307
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:3471
LIBSSH_API void ssh_channel_set_blocking(ssh_channel channel, int blocking)
Put the channel into blocking or nonblocking mode.
Definition channels.c:1795
LIBSSH_API int ssh_channel_close(ssh_channel channel)
Close a channel.
Definition channels.c:1444
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:2005
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:3136
LIBSSH_API int ssh_channel_request_pty(ssh_channel channel)
Request a PTY.
Definition channels.c:2087
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:2716
LIBSSH_API int ssh_channel_request_sftp(ssh_channel channel)
Request sftp subsystem on the channel.
Definition channels.c:2220
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:2673
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:2697
LIBSSH_API ssh_channel ssh_channel_accept_x11(ssh_channel channel, int timeout_ms)
Accept an X11 forwarding channel.
Definition channels.c:2398
LIBSSH_API int ssh_channel_request_exec(ssh_channel channel, const char *cmd)
Run a shell command without an interactive shell.
Definition channels.c:2845
LIBSSH_API int ssh_channel_write(ssh_channel channel, const void *data, uint32_t len)
Blocking write on a channel.
Definition channels.c:1726
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:1100
LIBSSH_API ssh_session ssh_channel_get_session(ssh_channel channel)
Recover the session in which belongs a channel.
Definition channels.c:3420
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:2607
LIBSSH_API int ssh_channel_request_env(ssh_channel channel, const char *name, const char *value)
Set environment variables.
Definition channels.c:2768
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:3821
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:1212
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:3539
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:2911
LIBSSH_API int ssh_channel_is_open(ssh_channel channel)
Check if the channel is open or not.
Definition channels.c:1740
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:3246
LIBSSH_API void ssh_channel_set_counter(ssh_channel channel, ssh_counter counter)
Set the channel data counter.
Definition channels.c:3800
LIBSSH_API int ssh_channel_is_closed(ssh_channel channel)
Check if the channel is closed or not.
Definition channels.c:1757
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:2414
LIBSSH_API int ssh_channel_is_eof(ssh_channel channel)
Check if remote has sent an EOF.
Definition channels.c:1772
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:3361
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:3107
LIBSSH_API void ssh_channel_free(ssh_channel channel)
Close and free a channel.
Definition channels.c:1276
LIBSSH_API ssh_channel ssh_channel_new(ssh_session session)
Allocate a new channel.
Definition channels.c:90
LIBSSH_API uint32_t ssh_channel_window_size(ssh_channel channel)
Get the remote window size.
Definition channels.c:1708
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:2274
LIBSSH_API int ssh_channel_open_x11(ssh_channel channel, const char *orig_addr, int orig_port)
Open a X11 channel.
Definition channels.c:3916
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:1139
LIBSSH_API int ssh_channel_request_shell(ssh_channel channel)
Request a shell.
Definition channels.c:2147
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:2956
LIBSSH_API int ssh_channel_open_session(ssh_channel channel)
Open a session channel (suited for a shell, not TCP forwarding).
Definition channels.c:1072
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:2107
LIBSSH_API int ssh_get_error_code(void *error)
Retrieve the error code from the last error.
Definition error.c:148
LIBSSH_API const char * ssh_get_error(void *error)
Retrieve the error text message from the last error.
Definition error.c:128
LIBSSH_API int ssh_set_log_userdata(void *data)
Set the userdata for the logging function.
Definition log.c:255
LIBSSH_API void * ssh_get_log_userdata(void)
Get the userdata of the logging function.
Definition log.c:239
LIBSSH_API int ssh_set_log_level(int level)
Set the log level of the library.
Definition log.c:195
LIBSSH_API int ssh_get_log_level(void)
Get the log level of the library.
Definition log.c:210
@ SSH_LOG_WARNING
Definition libssh.h:332
@ SSH_LOG_PACKET
Definition libssh.h:338
@ SSH_LOG_PROTOCOL
Definition libssh.h:335
@ SSH_LOG_FUNCTIONS
Definition libssh.h:341
@ SSH_LOG_NOLOG
Definition libssh.h:329
LIBSSH_API int ssh_message_type(ssh_message msg)
Get the type of the message.
Definition messages.c:624
LIBSSH_API int ssh_message_subtype(ssh_message msg)
Get the subtype of the message.
Definition messages.c:639
LIBSSH_API ssh_message ssh_message_get(ssh_session session)
Retrieve a SSH message from a SSH session.
Definition messages.c:591
LIBSSH_API void ssh_message_free(ssh_message msg)
Free a SSH message.
Definition messages.c:663
LIBSSH_API char * ssh_dirname(const char *path)
Parse directory component.
Definition misc.c:947
SSH_DEPRECATED LIBSSH_API void ssh_print_hexa(const char *descr, const unsigned char *what, size_t len)
Definition misc.c:513
LIBSSH_API int ssh_mkdir(const char *pathname, mode_t mode)
Attempts to create a directory with the given pathname.
Definition misc.c:1058
LIBSSH_API int ssh_get_random(void *where, int len, int strong)
Get random bytes.
Definition getrandom_crypto.c:47
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:484
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
LIBSSH_API const char * ssh_version(int req_version)
Check if libssh is the required version or get the version string.
Definition misc.c:735
LIBSSH_API char * ssh_basename(const char *path)
basename - parse filename component.
Definition misc.c:1006
LIBSSH_API void ssh_key_free(ssh_key key)
deallocate a SSH key
Definition pki.c:260
LIBSSH_API int ssh_key_is_private(const ssh_key k)
Check if the key is a private key.
Definition pki.c:826
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:1066
LIBSSH_API int ssh_sk_resident_keys_load(const struct ssh_pki_ctx_struct *pki_context, ssh_key **resident_keys_result, size_t *num_keys_found_result)
Load resident keys from FIDO2 security keys.
Definition pki_sk.c:770
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:94
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:1184
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:2641
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:1147
LIBSSH_API int ssh_pki_ctx_sk_callbacks_option_set(ssh_pki_ctx context, const char *name, const char *value, bool required)
Set a security key (FIDO2/U2F) callback option in the context. These options are passed to the sk_cal...
Definition pki_context.c:349
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:1380
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:731
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:845
LIBSSH_API int ssh_pki_generate_key(enum ssh_keytypes_e type, ssh_pki_ctx pki_context, ssh_key *pkey)
Generates a key pair.
Definition pki.c:2411
LIBSSH_API int ssh_pki_ctx_set_sk_pin_callback(ssh_pki_ctx context, ssh_auth_callback pin_callback, void *userdata)
Set the PIN callback function to get the PIN for security key authenticator access.
Definition pki_context.c:302
LIBSSH_API int ssh_pki_export_pubkey_file(const ssh_key key, const char *filename)
Export public key to file.
Definition pki.c:2679
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:2480
LIBSSH_API int ssh_pki_ctx_sk_callbacks_options_clear(ssh_pki_ctx context)
Clear all sk_callbacks options.
Definition pki_context.c:431
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:999
LIBSSH_API const char * ssh_key_type_to_char(enum ssh_keytypes_e type)
Convert a key type to a string.
Definition pki.c:410
LIBSSH_API uint32_t ssh_key_get_sk_flags(const ssh_key key)
Get security key (FIDO2) flags for a security key backed ssh_key.
Definition pki.c:298
LIBSSH_API ssh_pki_ctx ssh_pki_ctx_new(void)
Allocate a new generic PKI context container.
Definition pki_context.c:48
LIBSSH_API int sshsig_verify(const void *data, size_t data_length, const char *signature, const char *sig_namespace, ssh_key *sign_key)
Verifies an sshsig formatted signature against data.
Definition pki.c:3604
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:2746
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:2205
LIBSSH_API int sshsig_sign(const void *data, size_t data_length, ssh_key privkey, ssh_pki_ctx pki_context, const char *sig_namespace, enum sshsig_digest_e hash_alg, char **signature)
Signs data in sshsig compatible format.
Definition pki.c:3433
LIBSSH_API ssh_string ssh_key_get_sk_application(const ssh_key key)
Get the application (RP ID) associated with a security key.
Definition pki.c:320
LIBSSH_API int ssh_pki_import_cert_file(const char *filename, ssh_key *pkey)
Import a certificate from the given filename.
Definition pki.c:2246
LIBSSH_API int ssh_key_is_public(const ssh_key k)
Check if the key has/is a public key.
Definition pki.c:810
LIBSSH_API enum ssh_keytypes_e ssh_key_type(const ssh_key key)
returns the type of a ssh key
Definition pki.c:279
LIBSSH_API ssh_key ssh_key_new(void)
creates a new empty SSH key
Definition pki.c:112
LIBSSH_API void ssh_pki_ctx_free(ssh_pki_ctx context)
Free a generic PKI context container.
Definition pki_context.c:85
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:1896
LIBSSH_API int ssh_pki_ctx_get_sk_attestation_buffer(const struct ssh_pki_ctx_struct *context, ssh_buffer *attestation_buffer)
Get a copy of the attestation buffer from a PKI context.
Definition pki_context.c:469
LIBSSH_API ssh_string ssh_key_get_sk_user_id(const ssh_key key)
Get a copy of the user ID associated with a resident security key credential.
Definition pki.c:347
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:1289
SSH_DEPRECATED LIBSSH_API int ssh_pki_generate(enum ssh_keytypes_e type, int parameter, ssh_key *pkey)
Generates a key pair.
Definition pki.c:2386
LIBSSH_API ssh_key ssh_key_dup(const ssh_key key)
duplicates the key
Definition pki.c:208
LIBSSH_API int ssh_pki_ctx_options_set(ssh_pki_ctx context, enum ssh_pki_options_e option, const void *value)
Set various options for a PKI context.
Definition pki_context.c:180
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:2060
LIBSSH_API void ssh_event_free(ssh_event event)
Free an event context.
Definition poll.c:1185
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:831
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:890
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:965
LIBSSH_API int ssh_event_remove_session(ssh_event event, ssh_session session)
Remove a session object from an event context.
Definition poll.c:1114
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:1047
LIBSSH_API int ssh_event_remove_connector(ssh_event event, ssh_connector connector)
Remove a connector from an event context.
Definition poll.c:1171
LIBSSH_API int ssh_event_add_connector(ssh_event event, ssh_connector connector)
Add a connector to the SSH event loop.
Definition poll.c:1022
LIBSSH_API int ssh_event_remove_fd(ssh_event event, socket_t fd)
Remove a socket fd from an event context.
Definition poll.c:1067
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:1023
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:682
SSH_DEPRECATED LIBSSH_API int ssh_scp_close(ssh_scp scp)
Close the scp channel.
Definition scp.c:261
SSH_DEPRECATED LIBSSH_API int ssh_scp_init(ssh_scp scp)
Initialize the scp channel.
Definition scp.c:126
SSH_DEPRECATED LIBSSH_API int ssh_scp_leave_directory(ssh_scp scp)
Leave a directory.
Definition scp.c:435
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:1113
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:1197
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:484
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:587
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:1096
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:1132
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:66
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:344
SSH_DEPRECATED LIBSSH_API int ssh_scp_pull_request(ssh_scp scp)
Wait for a scp request (file, directory).
Definition scp.c:821
SSH_DEPRECATED LIBSSH_API void ssh_scp_free(ssh_scp scp)
Free a scp context.
Definition scp.c:308
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:935
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:981
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:1147
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:529
LIBSSH_API int ssh_connect(ssh_session session)
Connect to the ssh server.
Definition client.c:546
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:732
LIBSSH_API void ssh_clean_pubkey_hash(unsigned char **hash)
Deallocate the hash obtained by ssh_get_pubkey_hash.
Definition session.c:1223
LIBSSH_API const char * ssh_get_disconnect_message(ssh_session session)
Get the disconnect message from the server.
Definition session.c:950
LIBSSH_API int ssh_is_blocking(ssh_session session)
Return the blocking mode of libssh.
Definition session.c:623
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:706
LIBSSH_API void ssh_disconnect(ssh_session session)
Disconnect from a session (client or server).
Definition client.c:803
LIBSSH_API const char * ssh_get_serverbanner(ssh_session session)
get the server banner
Definition session.c:446
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:545
LIBSSH_API char * ssh_get_issue_banner(ssh_session session)
Get the issue banner from the server.
Definition client.c:701
LIBSSH_API void ssh_set_blocking(ssh_session session, int blocking)
Set the session in blocking/nonblocking mode.
Definition session.c:608
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
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:719
LIBSSH_API int ssh_is_connected(ssh_session session)
Check if we are connected.
Definition session.c:674
LIBSSH_API const char * ssh_get_kex_algo(ssh_session session)
get the name of the current key exchange algorithm.
Definition session.c:460
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
LIBSSH_API int ssh_get_server_publickey(ssh_session session, ssh_key *key)
Get the server public key from a session.
Definition session.c:1240
SSH_DEPRECATED LIBSSH_API char * ssh_dump_knownhost(ssh_session session)
This function is deprecated.
Definition known_hosts.c:446
LIBSSH_API int ssh_send_debug(ssh_session session, const char *message, int always_display)
Send a debug message.
Definition session.c:1072
LIBSSH_API int ssh_blocking_flush(ssh_session session, int timeout)
Blocking flush of the outgoing buffer.
Definition session.c:649
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:513
LIBSSH_API const char * ssh_copyright(void)
Copyright information.
Definition client.c:914
LIBSSH_API const char * ssh_get_clientbanner(ssh_session session)
get the client banner
Definition session.c:431
SSH_DEPRECATED LIBSSH_API int ssh_is_server_known(ssh_session session)
This function is deprecated.
Definition known_hosts.c:304
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:1295
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:674
LIBSSH_API int ssh_options_parse_config(ssh_session session, const char *filename)
Parse the ssh config file.
Definition options.c:1862
SSH_DEPRECATED LIBSSH_API int ssh_get_publickey(ssh_session session, ssh_key *key)
Definition session.c:1262
LIBSSH_API int ssh_get_version(ssh_session session)
Get the protocol version of the session.
Definition session.c:975
LIBSSH_API void ssh_set_counters(ssh_session session, ssh_counter scounter, ssh_counter rcounter)
Set the session data counters.
Definition session.c:1128
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:335
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
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
LIBSSH_API int ssh_options_getopt(ssh_session session, int *argcptr, char **argv)
Parse command line arguments.
Definition options.c:1680
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
LIBSSH_API void ssh_knownhosts_entry_free(struct ssh_knownhosts_entry *entry)
Free an allocated ssh_knownhosts_entry.
Definition knownhosts.c:155
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:749
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:1458
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
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:1556
LIBSSH_API ssh_session ssh_new(void)
Create a new ssh session.
Definition session.c:64
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:560
LIBSSH_API int ssh_send_ignore(ssh_session session, const char *data)
Send a message that should be ignored.
Definition session.c:1037
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:767
LIBSSH_API int ssh_get_status(ssh_session session)
Get session status.
Definition session.c:892
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:728
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
LIBSSH_API void ssh_silent_disconnect(ssh_session session)
Disconnect impolitely from a remote host by closing the socket.
Definition session.c:591
LIBSSH_API void ssh_free(ssh_session session)
Deallocate a SSH session handle.
Definition session.c:242
LIBSSH_API int ssh_get_poll_flags(ssh_session session)
Get poll flags for an external mainloop.
Definition session.c:930
LIBSSH_API int ssh_options_copy(ssh_session src, ssh_session *dest)
Duplicate the options of a session structure.
Definition options.c:70
SSH_DEPRECATED LIBSSH_API int ssh_write_knownhost(ssh_session session)
This function is deprecated.
Definition known_hosts.c:515
SSH_DEPRECATED LIBSSH_API int ssh_get_pubkey_hash(ssh_session session, unsigned char **hash)
Definition session.c:1139
LIBSSH_API socket_t ssh_get_fd(ssh_session session)
Get the fd of a connection.
Definition session.c:692
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
LIBSSH_API ssh_string ssh_string_from_char(const char *what)
Create a ssh string using a C string.
Definition string.c:109
LIBSSH_API ssh_string ssh_string_from_data(const void *data, size_t len)
Create a ssh string from an arbitrary data buffer.
Definition string.c:144
LIBSSH_API ssh_string ssh_string_new(size_t size)
Create a new SSH String object.
Definition string.c:56
LIBSSH_API void ssh_string_free_char(char *s)
Deallocate a char string object.
Definition string.c:252
LIBSSH_API int ssh_init(void)
Initialize global cryptographic data structures.
Definition init.c:156
LIBSSH_API int ssh_finalize(void)
Finalize and clean up all libssh and cryptographic data structures.
Definition init.c:241
Security key context structure.
Definition pki_context.h:33