libssh: include/libssh/libssh.h Source File

libssh 0.7.4

libssh.h
1 /*
2 * This file is part of the SSH Library
3 *
4 * Copyright (c) 2003-2009 by Aris Adamantiadis
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 #if defined _WIN32 || defined __CYGWIN__
25 #ifdef LIBSSH_STATIC
26 #define LIBSSH_API
27 #else
28 #ifdef LIBSSH_EXPORTS
29 #ifdef __GNUC__
30 #define LIBSSH_API __attribute__((dllexport))
31 #else
32 #define LIBSSH_API __declspec(dllexport)
33 #endif
34 #else
35 #ifdef __GNUC__
36 #define LIBSSH_API __attribute__((dllimport))
37 #else
38 #define LIBSSH_API __declspec(dllimport)
39 #endif
40 #endif
41 #endif
42 #else
43 #if __GNUC__ >= 4 && !defined(__OS2__)
44 #define LIBSSH_API __attribute__((visibility("default")))
45 #else
46 #define LIBSSH_API
47 #endif
48 #endif
49
50 #ifdef _MSC_VER
51 /* Visual Studio hasn't inttypes.h so it doesn't know uint32_t */
52 typedef int int32_t;
53 typedef unsigned int uint32_t;
54 typedef unsigned short uint16_t;
55 typedef unsigned char uint8_t;
56 typedef unsigned long long uint64_t;
57 typedef int mode_t;
58 #else /* _MSC_VER */
59 #include <unistd.h>
60 #include <inttypes.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 /* libssh version macros */
75 #define SSH_VERSION_INT(a, b, c) ((a) << 16 | (b) << 8 | (c))
76 #define SSH_VERSION_DOT(a, b, c) a ##.## b ##.## c
77 #define SSH_VERSION(a, b, c) SSH_VERSION_DOT(a, b, c)
78
79 /* libssh version */
80 #define LIBSSH_VERSION_MAJOR 0
81 #define LIBSSH_VERSION_MINOR 7
82 #define LIBSSH_VERSION_MICRO 4
83
84 #define LIBSSH_VERSION_INT SSH_VERSION_INT(LIBSSH_VERSION_MAJOR, \
85 LIBSSH_VERSION_MINOR, \
86 LIBSSH_VERSION_MICRO)
87 #define LIBSSH_VERSION SSH_VERSION(LIBSSH_VERSION_MAJOR, \
88 LIBSSH_VERSION_MINOR, \
89 LIBSSH_VERSION_MICRO)
90
91 /* GCC have printf type attribute check. */
92 #ifdef __GNUC__
93 #define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
94 #else
95 #define PRINTF_ATTRIBUTE(a,b)
96 #endif /* __GNUC__ */
97
98 #ifdef __GNUC__
99 #define SSH_DEPRECATED __attribute__ ((deprecated))
100 #else
101 #define SSH_DEPRECATED
102 #endif
103
104 #ifdef __cplusplus
105 extern "C" {
106 #endif
107
108 struct ssh_counter_struct {
109 uint64_t in_bytes;
110 uint64_t out_bytes;
111 uint64_t in_packets;
112 uint64_t out_packets;
113 };
114 typedef struct ssh_counter_struct *ssh_counter;
115
116 typedef struct ssh_agent_struct* ssh_agent;
117 typedef struct ssh_buffer_struct* ssh_buffer;
118 typedef struct ssh_channel_struct* ssh_channel;
119 typedef struct ssh_message_struct* ssh_message;
120 typedef struct ssh_pcap_file_struct* ssh_pcap_file;
121 typedef struct ssh_key_struct* ssh_key;
122 typedef struct ssh_scp_struct* ssh_scp;
123 typedef struct ssh_session_struct* ssh_session;
124 typedef struct ssh_string_struct* ssh_string;
125 typedef struct ssh_event_struct* ssh_event;
126 typedef void* ssh_gssapi_creds;
127
128 /* Socket type */
129 #ifdef _WIN32
130 #ifndef socket_t
131 typedef SOCKET socket_t;
132 #endif /* socket_t */
133 #else /* _WIN32 */
134 #ifndef socket_t
135 typedef int socket_t;
136 #endif
137 #endif /* _WIN32 */
138
139 #define SSH_INVALID_SOCKET ((socket_t) -1)
140
141 /* the offsets of methods */
142 enum ssh_kex_types_e {
143 SSH_KEX=0,
144 SSH_HOSTKEYS,
145 SSH_CRYPT_C_S,
146 SSH_CRYPT_S_C,
147 SSH_MAC_C_S,
148 SSH_MAC_S_C,
149 SSH_COMP_C_S,
150 SSH_COMP_S_C,
151 SSH_LANG_C_S,
152 SSH_LANG_S_C
153 };
154
155 #define SSH_CRYPT 2
156 #define SSH_MAC 3
157 #define SSH_COMP 4
158 #define SSH_LANG 5
159
160 enum ssh_auth_e {
161 SSH_AUTH_SUCCESS=0,
162 SSH_AUTH_DENIED,
163 SSH_AUTH_PARTIAL,
164 SSH_AUTH_INFO,
165 SSH_AUTH_AGAIN,
166 SSH_AUTH_ERROR=-1
167 };
168
169 /* auth flags */
170 #define SSH_AUTH_METHOD_UNKNOWN 0
171 #define SSH_AUTH_METHOD_NONE 0x0001
172 #define SSH_AUTH_METHOD_PASSWORD 0x0002
173 #define SSH_AUTH_METHOD_PUBLICKEY 0x0004
174 #define SSH_AUTH_METHOD_HOSTBASED 0x0008
175 #define SSH_AUTH_METHOD_INTERACTIVE 0x0010
176 #define SSH_AUTH_METHOD_GSSAPI_MIC 0x0020
177
178 /* messages */
179 enum ssh_requests_e {
180 SSH_REQUEST_AUTH=1,
181 SSH_REQUEST_CHANNEL_OPEN,
182 SSH_REQUEST_CHANNEL,
183 SSH_REQUEST_SERVICE,
184 SSH_REQUEST_GLOBAL
185 };
186
187 enum ssh_channel_type_e {
188 SSH_CHANNEL_UNKNOWN=0,
189 SSH_CHANNEL_SESSION,
190 SSH_CHANNEL_DIRECT_TCPIP,
191 SSH_CHANNEL_FORWARDED_TCPIP,
192 SSH_CHANNEL_X11
193 };
194
195 enum ssh_channel_requests_e {
196 SSH_CHANNEL_REQUEST_UNKNOWN=0,
197 SSH_CHANNEL_REQUEST_PTY,
198 SSH_CHANNEL_REQUEST_EXEC,
199 SSH_CHANNEL_REQUEST_SHELL,
200 SSH_CHANNEL_REQUEST_ENV,
201 SSH_CHANNEL_REQUEST_SUBSYSTEM,
202 SSH_CHANNEL_REQUEST_WINDOW_CHANGE,
203 SSH_CHANNEL_REQUEST_X11
204 };
205
206 enum ssh_global_requests_e {
207 SSH_GLOBAL_REQUEST_UNKNOWN=0,
208 SSH_GLOBAL_REQUEST_TCPIP_FORWARD,
209 SSH_GLOBAL_REQUEST_CANCEL_TCPIP_FORWARD,
210 };
211
212 enum ssh_publickey_state_e {
213 SSH_PUBLICKEY_STATE_ERROR=-1,
214 SSH_PUBLICKEY_STATE_NONE=0,
215 SSH_PUBLICKEY_STATE_VALID=1,
216 SSH_PUBLICKEY_STATE_WRONG=2
217 };
218
219 /* Status flags */
221 #define SSH_CLOSED 0x01
222
223 #define SSH_READ_PENDING 0x02
224
225 #define SSH_CLOSED_ERROR 0x04
226
227 #define SSH_WRITE_PENDING 0x08
228
229 enum ssh_server_known_e {
230 SSH_SERVER_ERROR=-1,
231 SSH_SERVER_NOT_KNOWN=0,
232 SSH_SERVER_KNOWN_OK,
233 SSH_SERVER_KNOWN_CHANGED,
234 SSH_SERVER_FOUND_OTHER,
235 SSH_SERVER_FILE_NOT_FOUND
236 };
237
238 #ifndef MD5_DIGEST_LEN
239 #define MD5_DIGEST_LEN 16
240 #endif
241 /* errors */
242
243 enum ssh_error_types_e {
244 SSH_NO_ERROR=0,
245 SSH_REQUEST_DENIED,
246 SSH_FATAL,
247 SSH_EINTR
248 };
249
250 /* some types for keys */
251 enum ssh_keytypes_e{
252 SSH_KEYTYPE_UNKNOWN=0,
253 SSH_KEYTYPE_DSS=1,
254 SSH_KEYTYPE_RSA,
255 SSH_KEYTYPE_RSA1,
256 SSH_KEYTYPE_ECDSA,
257 SSH_KEYTYPE_ED25519
258 };
259
260 enum ssh_keycmp_e {
261 SSH_KEY_CMP_PUBLIC = 0,
262 SSH_KEY_CMP_PRIVATE
263 };
264
265 /* Error return codes */
266 #define SSH_OK 0 /* No error */
267 #define SSH_ERROR -1 /* Error of some kind */
268 #define SSH_AGAIN -2 /* The nonblocking call must be repeated */
269 #define SSH_EOF -127 /* We have already a eof */
270
277 enum {
280 SSH_LOG_NOLOG=0,
283 SSH_LOG_WARNING,
286 SSH_LOG_PROTOCOL,
289 SSH_LOG_PACKET,
292 SSH_LOG_FUNCTIONS
293 };
295 #define SSH_LOG_RARE SSH_LOG_WARNING
296
305 #define SSH_LOG_NONE 0
306
307 #define SSH_LOG_WARN 1
308
309 #define SSH_LOG_INFO 2
310
311 #define SSH_LOG_DEBUG 3
312
313 #define SSH_LOG_TRACE 4
314
317 enum ssh_options_e {
318 SSH_OPTIONS_HOST,
319 SSH_OPTIONS_PORT,
320 SSH_OPTIONS_PORT_STR,
321 SSH_OPTIONS_FD,
322 SSH_OPTIONS_USER,
323 SSH_OPTIONS_SSH_DIR,
324 SSH_OPTIONS_IDENTITY,
325 SSH_OPTIONS_ADD_IDENTITY,
326 SSH_OPTIONS_KNOWNHOSTS,
327 SSH_OPTIONS_TIMEOUT,
328 SSH_OPTIONS_TIMEOUT_USEC,
329 SSH_OPTIONS_SSH1,
330 SSH_OPTIONS_SSH2,
331 SSH_OPTIONS_LOG_VERBOSITY,
332 SSH_OPTIONS_LOG_VERBOSITY_STR,
333 SSH_OPTIONS_CIPHERS_C_S,
334 SSH_OPTIONS_CIPHERS_S_C,
335 SSH_OPTIONS_COMPRESSION_C_S,
336 SSH_OPTIONS_COMPRESSION_S_C,
337 SSH_OPTIONS_PROXYCOMMAND,
338 SSH_OPTIONS_BINDADDR,
339 SSH_OPTIONS_STRICTHOSTKEYCHECK,
340 SSH_OPTIONS_COMPRESSION,
341 SSH_OPTIONS_COMPRESSION_LEVEL,
342 SSH_OPTIONS_KEY_EXCHANGE,
343 SSH_OPTIONS_HOSTKEYS,
344 SSH_OPTIONS_GSSAPI_SERVER_IDENTITY,
345 SSH_OPTIONS_GSSAPI_CLIENT_IDENTITY,
346 SSH_OPTIONS_GSSAPI_DELEGATE_CREDENTIALS,
347 SSH_OPTIONS_HMAC_C_S,
348 SSH_OPTIONS_HMAC_S_C,
349 };
350
351 enum {
353 SSH_SCP_WRITE,
355 SSH_SCP_READ,
356 SSH_SCP_RECURSIVE=0x10
357 };
358
359 enum ssh_scp_request_types {
361 SSH_SCP_REQUEST_NEWDIR=1,
363 SSH_SCP_REQUEST_NEWFILE,
365 SSH_SCP_REQUEST_EOF,
367 SSH_SCP_REQUEST_ENDDIR,
369 SSH_SCP_REQUEST_WARNING
370 };
371
372 LIBSSH_API int ssh_blocking_flush(ssh_session session, int timeout);
373 LIBSSH_API ssh_channel ssh_channel_accept_x11(ssh_channel channel, int timeout_ms);
374 LIBSSH_API int ssh_channel_change_pty_size(ssh_channel channel,int cols,int rows);
375 LIBSSH_API int ssh_channel_close(ssh_channel channel);
376 LIBSSH_API void ssh_channel_free(ssh_channel channel);
377 LIBSSH_API int ssh_channel_get_exit_status(ssh_channel channel);
378 LIBSSH_API ssh_session ssh_channel_get_session(ssh_channel channel);
379 LIBSSH_API int ssh_channel_is_closed(ssh_channel channel);
380 LIBSSH_API int ssh_channel_is_eof(ssh_channel channel);
381 LIBSSH_API int ssh_channel_is_open(ssh_channel channel);
382 LIBSSH_API ssh_channel ssh_channel_new(ssh_session session);
383 LIBSSH_API int ssh_channel_open_auth_agent(ssh_channel channel);
384 LIBSSH_API int ssh_channel_open_forward(ssh_channel channel, const char *remotehost,
385 int remoteport, const char *sourcehost, int localport);
386 LIBSSH_API int ssh_channel_open_session(ssh_channel channel);
387 LIBSSH_API int ssh_channel_open_x11(ssh_channel channel, const char *orig_addr, int orig_port);
388 LIBSSH_API int ssh_channel_poll(ssh_channel channel, int is_stderr);
389 LIBSSH_API int ssh_channel_poll_timeout(ssh_channel channel, int timeout, int is_stderr);
390 LIBSSH_API int ssh_channel_read(ssh_channel channel, void *dest, uint32_t count, int is_stderr);
391 LIBSSH_API int ssh_channel_read_timeout(ssh_channel channel, void *dest, uint32_t count, int is_stderr, int timeout_ms);
392 LIBSSH_API int ssh_channel_read_nonblocking(ssh_channel channel, void *dest, uint32_t count,
393 int is_stderr);
394 LIBSSH_API int ssh_channel_request_env(ssh_channel channel, const char *name, const char *value);
395 LIBSSH_API int ssh_channel_request_exec(ssh_channel channel, const char *cmd);
396 LIBSSH_API int ssh_channel_request_pty(ssh_channel channel);
397 LIBSSH_API int ssh_channel_request_pty_size(ssh_channel channel, const char *term,
398 int cols, int rows);
399 LIBSSH_API int ssh_channel_request_shell(ssh_channel channel);
400 LIBSSH_API int ssh_channel_request_send_signal(ssh_channel channel, const char *signum);
401 LIBSSH_API int ssh_channel_request_sftp(ssh_channel channel);
402 LIBSSH_API int ssh_channel_request_subsystem(ssh_channel channel, const char *subsystem);
403 LIBSSH_API int ssh_channel_request_x11(ssh_channel channel, int single_connection, const char *protocol,
404 const char *cookie, int screen_number);
405 LIBSSH_API int ssh_channel_send_eof(ssh_channel channel);
406 LIBSSH_API int ssh_channel_select(ssh_channel *readchans, ssh_channel *writechans, ssh_channel *exceptchans, struct
407 timeval * timeout);
408 LIBSSH_API void ssh_channel_set_blocking(ssh_channel channel, int blocking);
409 LIBSSH_API void ssh_channel_set_counter(ssh_channel channel,
410 ssh_counter counter);
411 LIBSSH_API int ssh_channel_write(ssh_channel channel, const void *data, uint32_t len);
412 LIBSSH_API uint32_t ssh_channel_window_size(ssh_channel channel);
413
414 LIBSSH_API char *ssh_basename (const char *path);
415 LIBSSH_API void ssh_clean_pubkey_hash(unsigned char **hash);
416 LIBSSH_API int ssh_connect(ssh_session session);
417 LIBSSH_API const char *ssh_copyright(void);
418 LIBSSH_API void ssh_disconnect(ssh_session session);
419 LIBSSH_API char *ssh_dirname (const char *path);
420 LIBSSH_API int ssh_finalize(void);
421
422 /* REVERSE PORT FORWARDING */
423 LIBSSH_API ssh_channel ssh_channel_accept_forward(ssh_session session,
424 int timeout_ms,
425 int *destination_port);
426 LIBSSH_API int ssh_channel_cancel_forward(ssh_session session,
427 const char *address,
428 int port);
429 LIBSSH_API int ssh_channel_listen_forward(ssh_session session,
430 const char *address,
431 int port,
432 int *bound_port);
433
434 LIBSSH_API void ssh_free(ssh_session session);
435 LIBSSH_API const char *ssh_get_disconnect_message(ssh_session session);
436 LIBSSH_API const char *ssh_get_error(void *error);
437 LIBSSH_API int ssh_get_error_code(void *error);
438 LIBSSH_API socket_t ssh_get_fd(ssh_session session);
439 LIBSSH_API char *ssh_get_hexa(const unsigned char *what, size_t len);
440 LIBSSH_API char *ssh_get_issue_banner(ssh_session session);
441 LIBSSH_API int ssh_get_openssh_version(ssh_session session);
442
443 LIBSSH_API int ssh_get_publickey(ssh_session session, ssh_key *key);
444
445 enum ssh_publickey_hash_type {
446 SSH_PUBLICKEY_HASH_SHA1,
447 SSH_PUBLICKEY_HASH_MD5
448 };
449 LIBSSH_API int ssh_get_publickey_hash(const ssh_key key,
450 enum ssh_publickey_hash_type type,
451 unsigned char **hash,
452 size_t *hlen);
453
454 /* DEPRECATED FUNCTIONS */
455 SSH_DEPRECATED LIBSSH_API int ssh_get_pubkey_hash(ssh_session session, unsigned char **hash);
456 SSH_DEPRECATED LIBSSH_API ssh_channel ssh_forward_accept(ssh_session session, int timeout_ms);
457 SSH_DEPRECATED LIBSSH_API int ssh_forward_cancel(ssh_session session, const char *address, int port);
458 SSH_DEPRECATED LIBSSH_API int ssh_forward_listen(ssh_session session, const char *address, int port, int *bound_port);
459
460
461 LIBSSH_API int ssh_get_random(void *where,int len,int strong);
462 LIBSSH_API int ssh_get_version(ssh_session session);
463 LIBSSH_API int ssh_get_status(ssh_session session);
464 LIBSSH_API int ssh_get_poll_flags(ssh_session session);
465 LIBSSH_API int ssh_init(void);
466 LIBSSH_API int ssh_is_blocking(ssh_session session);
467 LIBSSH_API int ssh_is_connected(ssh_session session);
468 LIBSSH_API int ssh_is_server_known(ssh_session session);
469
470 /* LOGGING */
471 LIBSSH_API int ssh_set_log_level(int level);
472 LIBSSH_API int ssh_get_log_level(void);
473 LIBSSH_API void *ssh_get_log_userdata(void);
474 LIBSSH_API int ssh_set_log_userdata(void *data);
475 LIBSSH_API void _ssh_log(int verbosity,
476 const char *function,
477 const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
478
479 /* legacy */
480 SSH_DEPRECATED LIBSSH_API void ssh_log(ssh_session session,
481 int prioriry,
482 const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
483
484 LIBSSH_API ssh_channel ssh_message_channel_request_open_reply_accept(ssh_message msg);
485 LIBSSH_API int ssh_message_channel_request_reply_success(ssh_message msg);
486 LIBSSH_API void ssh_message_free(ssh_message msg);
487 LIBSSH_API ssh_message ssh_message_get(ssh_session session);
488 LIBSSH_API int ssh_message_subtype(ssh_message msg);
489 LIBSSH_API int ssh_message_type(ssh_message msg);
490 LIBSSH_API int ssh_mkdir (const char *pathname, mode_t mode);
491 LIBSSH_API ssh_session ssh_new(void);
492
493 LIBSSH_API int ssh_options_copy(ssh_session src, ssh_session *dest);
494 LIBSSH_API int ssh_options_getopt(ssh_session session, int *argcptr, char **argv);
495 LIBSSH_API int ssh_options_parse_config(ssh_session session, const char *filename);
496 LIBSSH_API int ssh_options_set(ssh_session session, enum ssh_options_e type,
497 const void *value);
498 LIBSSH_API int ssh_options_get(ssh_session session, enum ssh_options_e type,
499 char **value);
500 LIBSSH_API int ssh_options_get_port(ssh_session session, unsigned int * port_target);
501 LIBSSH_API int ssh_pcap_file_close(ssh_pcap_file pcap);
502 LIBSSH_API void ssh_pcap_file_free(ssh_pcap_file pcap);
503 LIBSSH_API ssh_pcap_file ssh_pcap_file_new(void);
504 LIBSSH_API int ssh_pcap_file_open(ssh_pcap_file pcap, const char *filename);
505
519 typedef int (*ssh_auth_callback) (const char *prompt, char *buf, size_t len,
520 int echo, int verify, void *userdata);
521
522 LIBSSH_API ssh_key ssh_key_new(void);
523 LIBSSH_API void ssh_key_free (ssh_key key);
524 LIBSSH_API enum ssh_keytypes_e ssh_key_type(const ssh_key key);
525 LIBSSH_API const char *ssh_key_type_to_char(enum ssh_keytypes_e type);
526 LIBSSH_API enum ssh_keytypes_e ssh_key_type_from_name(const char *name);
527 LIBSSH_API int ssh_key_is_public(const ssh_key k);
528 LIBSSH_API int ssh_key_is_private(const ssh_key k);
529 LIBSSH_API int ssh_key_cmp(const ssh_key k1,
530 const ssh_key k2,
531 enum ssh_keycmp_e what);
532
533 LIBSSH_API int ssh_pki_generate(enum ssh_keytypes_e type, int parameter,
534 ssh_key *pkey);
535 LIBSSH_API int ssh_pki_import_privkey_base64(const char *b64_key,
536 const char *passphrase,
537 ssh_auth_callback auth_fn,
538 void *auth_data,
539 ssh_key *pkey);
540 LIBSSH_API int ssh_pki_import_privkey_file(const char *filename,
541 const char *passphrase,
542 ssh_auth_callback auth_fn,
543 void *auth_data,
544 ssh_key *pkey);
545 LIBSSH_API int ssh_pki_export_privkey_file(const ssh_key privkey,
546 const char *passphrase,
547 ssh_auth_callback auth_fn,
548 void *auth_data,
549 const char *filename);
550
551 LIBSSH_API int ssh_pki_import_pubkey_base64(const char *b64_key,
552 enum ssh_keytypes_e type,
553 ssh_key *pkey);
554 LIBSSH_API int ssh_pki_import_pubkey_file(const char *filename,
555 ssh_key *pkey);
556
557 LIBSSH_API int ssh_pki_export_privkey_to_pubkey(const ssh_key privkey,
558 ssh_key *pkey);
559 LIBSSH_API int ssh_pki_export_pubkey_base64(const ssh_key key,
560 char **b64_key);
561 LIBSSH_API int ssh_pki_export_pubkey_file(const ssh_key key,
562 const char *filename);
563
564 LIBSSH_API const char *ssh_pki_key_ecdsa_name(const ssh_key key);
565
566 LIBSSH_API void ssh_print_hexa(const char *descr, const unsigned char *what, size_t len);
567 LIBSSH_API int ssh_send_ignore (ssh_session session, const char *data);
568 LIBSSH_API int ssh_send_debug (ssh_session session, const char *message, int always_display);
569 LIBSSH_API void ssh_gssapi_set_creds(ssh_session session, const ssh_gssapi_creds creds);
570 LIBSSH_API int ssh_scp_accept_request(ssh_scp scp);
571 LIBSSH_API int ssh_scp_close(ssh_scp scp);
572 LIBSSH_API int ssh_scp_deny_request(ssh_scp scp, const char *reason);
573 LIBSSH_API void ssh_scp_free(ssh_scp scp);
574 LIBSSH_API int ssh_scp_init(ssh_scp scp);
575 LIBSSH_API int ssh_scp_leave_directory(ssh_scp scp);
576 LIBSSH_API ssh_scp ssh_scp_new(ssh_session session, int mode, const char *location);
577 LIBSSH_API int ssh_scp_pull_request(ssh_scp scp);
578 LIBSSH_API int ssh_scp_push_directory(ssh_scp scp, const char *dirname, int mode);
579 LIBSSH_API int ssh_scp_push_file(ssh_scp scp, const char *filename, size_t size, int perms);
580 LIBSSH_API int ssh_scp_push_file64(ssh_scp scp, const char *filename, uint64_t size, int perms);
581 LIBSSH_API int ssh_scp_read(ssh_scp scp, void *buffer, size_t size);
582 LIBSSH_API const char *ssh_scp_request_get_filename(ssh_scp scp);
583 LIBSSH_API int ssh_scp_request_get_permissions(ssh_scp scp);
584 LIBSSH_API size_t ssh_scp_request_get_size(ssh_scp scp);
585 LIBSSH_API uint64_t ssh_scp_request_get_size64(ssh_scp scp);
586 LIBSSH_API const char *ssh_scp_request_get_warning(ssh_scp scp);
587 LIBSSH_API int ssh_scp_write(ssh_scp scp, const void *buffer, size_t len);
588 LIBSSH_API int ssh_select(ssh_channel *channels, ssh_channel *outchannels, socket_t maxfd,
589 fd_set *readfds, struct timeval *timeout);
590 LIBSSH_API int ssh_service_request(ssh_session session, const char *service);
591 LIBSSH_API int ssh_set_agent_channel(ssh_session session, ssh_channel channel);
592 LIBSSH_API int ssh_set_agent_socket(ssh_session session, socket_t fd);
593 LIBSSH_API void ssh_set_blocking(ssh_session session, int blocking);
594 LIBSSH_API void ssh_set_counters(ssh_session session, ssh_counter scounter,
595 ssh_counter rcounter);
596 LIBSSH_API void ssh_set_fd_except(ssh_session session);
597 LIBSSH_API void ssh_set_fd_toread(ssh_session session);
598 LIBSSH_API void ssh_set_fd_towrite(ssh_session session);
599 LIBSSH_API void ssh_silent_disconnect(ssh_session session);
600 LIBSSH_API int ssh_set_pcap_file(ssh_session session, ssh_pcap_file pcapfile);
601
602 /* USERAUTH */
603 LIBSSH_API int ssh_userauth_none(ssh_session session, const char *username);
604 LIBSSH_API int ssh_userauth_list(ssh_session session, const char *username);
605 LIBSSH_API int ssh_userauth_try_publickey(ssh_session session,
606 const char *username,
607 const ssh_key pubkey);
608 LIBSSH_API int ssh_userauth_publickey(ssh_session session,
609 const char *username,
610 const ssh_key privkey);
611 #ifndef _WIN32
612 LIBSSH_API int ssh_userauth_agent(ssh_session session,
613 const char *username);
614 #endif
615 LIBSSH_API int ssh_userauth_publickey_auto(ssh_session session,
616 const char *username,
617 const char *passphrase);
618 LIBSSH_API int ssh_userauth_password(ssh_session session,
619 const char *username,
620 const char *password);
621
622 LIBSSH_API int ssh_userauth_kbdint(ssh_session session, const char *user, const char *submethods);
623 LIBSSH_API const char *ssh_userauth_kbdint_getinstruction(ssh_session session);
624 LIBSSH_API const char *ssh_userauth_kbdint_getname(ssh_session session);
625 LIBSSH_API int ssh_userauth_kbdint_getnprompts(ssh_session session);
626 LIBSSH_API const char *ssh_userauth_kbdint_getprompt(ssh_session session, unsigned int i, char *echo);
627 LIBSSH_API int ssh_userauth_kbdint_getnanswers(ssh_session session);
628 LIBSSH_API const char *ssh_userauth_kbdint_getanswer(ssh_session session, unsigned int i);
629 LIBSSH_API int ssh_userauth_kbdint_setanswer(ssh_session session, unsigned int i,
630 const char *answer);
631 LIBSSH_API int ssh_userauth_gssapi(ssh_session session);
632 LIBSSH_API const char *ssh_version(int req_version);
633 LIBSSH_API int ssh_write_knownhost(ssh_session session);
634
635 LIBSSH_API void ssh_string_burn(ssh_string str);
636 LIBSSH_API ssh_string ssh_string_copy(ssh_string str);
637 LIBSSH_API void *ssh_string_data(ssh_string str);
638 LIBSSH_API int ssh_string_fill(ssh_string str, const void *data, size_t len);
639 LIBSSH_API void ssh_string_free(ssh_string str);
640 LIBSSH_API ssh_string ssh_string_from_char(const char *what);
641 LIBSSH_API size_t ssh_string_len(ssh_string str);
642 LIBSSH_API ssh_string ssh_string_new(size_t size);
643 LIBSSH_API const char *ssh_string_get_char(ssh_string str);
644 LIBSSH_API char *ssh_string_to_char(ssh_string str);
645 LIBSSH_API void ssh_string_free_char(char *s);
646
647 LIBSSH_API int ssh_getpass(const char *prompt, char *buf, size_t len, int echo,
648 int verify);
649
650
651 typedef int (*ssh_event_callback)(socket_t fd, int revents, void *userdata);
652
653 LIBSSH_API ssh_event ssh_event_new(void);
654 LIBSSH_API int ssh_event_add_fd(ssh_event event, socket_t fd, short events,
655 ssh_event_callback cb, void *userdata);
656 LIBSSH_API int ssh_event_add_session(ssh_event event, ssh_session session);
657 LIBSSH_API int ssh_event_dopoll(ssh_event event, int timeout);
658 LIBSSH_API int ssh_event_remove_fd(ssh_event event, socket_t fd);
659 LIBSSH_API int ssh_event_remove_session(ssh_event event, ssh_session session);
660 LIBSSH_API void ssh_event_free(ssh_event event);
661 LIBSSH_API const char* ssh_get_clientbanner(ssh_session session);
662 LIBSSH_API const char* ssh_get_serverbanner(ssh_session session);
663 LIBSSH_API const char* ssh_get_kex_algo(ssh_session session);
664 LIBSSH_API const char* ssh_get_cipher_in(ssh_session session);
665 LIBSSH_API const char* ssh_get_cipher_out(ssh_session session);
666 LIBSSH_API const char* ssh_get_hmac_in(ssh_session session);
667 LIBSSH_API const char* ssh_get_hmac_out(ssh_session session);
668
669 #ifndef LIBSSH_LEGACY_0_4
670 #include "libssh/legacy.h"
671 #endif
672
673 #ifdef __cplusplus
674 }
675 #endif
676 #endif /* _LIBSSH_H */
677 /* vim: set ts=2 sw=2 et cindent: */
ssh_set_log_userdata
int ssh_set_log_userdata(void *data)
Set the userdata for the logging function.
Definition: log.c:232
ssh_get_log_userdata
void * ssh_get_log_userdata(void)
Get the userdata of the logging function.
Definition: log.c:216
ssh_pki_export_privkey_to_pubkey
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:1101
ssh_userauth_kbdint
int ssh_userauth_kbdint(ssh_session session, const char *user, const char *submethods)
Try to authenticate through the "keyboard-interactive" method.
Definition: auth.c:1536
ssh_scp_init
int ssh_scp_init(ssh_scp scp)
Initialize the scp channel.
Definition: scp.c:95
ssh_channel_read_timeout
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:2627
ssh_options_get
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:940
ssh_get_pubkey_hash
int ssh_get_pubkey_hash(ssh_session session, unsigned char **hash)
Definition: dh.c:901
ssh_string_to_char
char * ssh_string_to_char(struct ssh_string_struct *s)
Convert a SSH string to a C nul-terminated string.
Definition: string.c:176
ssh_channel_select
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:3021
ssh_options_parse_config
int ssh_options_parse_config(ssh_session session, const char *filename)
Parse the ssh config file.
Definition: options.c:1200
ssh_channel_request_x11
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:1864
ssh_key_type_to_char
const char * ssh_key_type_to_char(enum ssh_keytypes_e type)
Convert a key type to a string.
Definition: pki.c:205
ssh_channel_request_shell
int ssh_channel_request_shell(ssh_channel channel)
Request a shell.
Definition: channels.c:1754
ssh_init
int ssh_init(void)
Initialize global cryptographic data structures.
Definition: init.c:53
ssh_message_type
int ssh_message_type(ssh_message msg)
Get the type of the message.
Definition: messages.c:463
ssh_send_debug
int ssh_send_debug(ssh_session session, const char *message, int always_display)
Send a debug message.
Definition: session.c:867
ssh_get_cipher_in
const char * ssh_get_cipher_in(ssh_session session)
get the name of the input cipher for the given session.
Definition: session.c:369
ssh_channel_open_forward
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:937
ssh_channel_is_eof
int ssh_channel_is_eof(ssh_channel channel)
Check if remote has sent an EOF.
Definition: channels.c:1412
ssh_set_log_level
int ssh_set_log_level(int level)
Set the log level of the library.
Definition: log.c:178
ssh_channel_send_eof
int ssh_channel_send_eof(ssh_channel channel)
Send an end of file on the channel.
Definition: channels.c:1065
ssh_scp_free
void ssh_scp_free(ssh_scp scp)
Free a scp context.
Definition: scp.c:199
ssh_clean_pubkey_hash
void ssh_clean_pubkey_hash(unsigned char **hash)
Deallocate the hash obtained by ssh_get_pubkey_hash.
Definition: dh.c:947
ssh_channel_close
int ssh_channel_close(ssh_channel channel)
Close a channel.
Definition: channels.c:1117
ssh_pki_export_privkey_file
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:548
ssh_set_fd_toread
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:544
ssh_key_is_public
int ssh_key_is_public(const ssh_key k)
Check if the key has/is a public key.
Definition: pki.c:269
ssh_scp_leave_directory
int ssh_scp_leave_directory(ssh_scp scp)
Leave a directory.
Definition: scp.c:271
ssh_string_new
ssh_string ssh_string_new(size_t size)
Create a new SSH String object.
Definition: string.c:53
ssh_scp_deny_request
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:644
ssh_key_is_private
int ssh_key_is_private(const ssh_key k)
Check if the key is a private key.
Definition: pki.c:284
ssh_get_openssh_version
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:672
ssh_channel_open_auth_agent
int ssh_channel_open_auth_agent(ssh_channel channel)
Open an agent authentication forwarding channel.
Definition: channels.c:893
ssh_version
const char * ssh_version(int req_version)
Check if libssh is the required version or get the version string.
Definition: misc.c:349
ssh_message_get
ssh_message ssh_message_get(ssh_session session)
Retrieve a SSH message from a SSH session.
Definition: messages.c:436
ssh_userauth_list
int ssh_userauth_list(ssh_session session, const char *username)
Get available authentication methods from the server.
Definition: auth.c:318
ssh_get_error
const char * ssh_get_error(void *error)
Retrieve the error text message from the last error.
Definition: error.c:111
SSH_LOG_PACKET
Lower level protocol infomations, packet level.
Definition: libssh.h:289
ssh_channel_write
int ssh_channel_write(ssh_channel channel, const void *data, uint32_t len)
Blocking write on a channel.
Definition: channels.c:1369
ssh_scp_accept_request
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:673
ssh_event_add_session
int ssh_event_add_session(ssh_event event, ssh_session session)
remove the poll handle from session and assign them to a event, when used in blocking mode...
Definition: poll.c:787
ssh_pki_export_pubkey_base64
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:1167
ssh_channel_request_pty_size
int ssh_channel_request_pty_size(ssh_channel channel, const char *term, int cols, int rows)
Request a pty with a specific type and size.
Definition: channels.c:1618
ssh_channel_request_subsystem
int ssh_channel_request_subsystem(ssh_channel channel, const char *subsystem)
Request a subsystem (for example "sftp").
Definition: channels.c:1780
ssh_pki_generate
int ssh_pki_generate(enum ssh_keytypes_e type, int parameter, ssh_key *pkey)
Generates a keypair.
Definition: pki.c:1036
ssh_string_from_char
ssh_string ssh_string_from_char(const char *what)
Create a ssh string using a C string.
Definition: string.c:103
ssh_getpass
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_event_dopoll
int ssh_event_dopoll(ssh_event event, int timeout)
Poll all the sockets and sessions associated through an event object.
Definition: poll.c:839
ssh_get_version
int ssh_get_version(ssh_session session)
Get the protocol version of the session.
Definition: session.c:797
ssh_channel_request_env
int ssh_channel_request_env(ssh_channel channel, const char *name, const char *value)
Set environment variables.
Definition: channels.c:2298
ssh_set_fd_except
void ssh_set_fd_except(ssh_session session)
Tell the session it has an exception to catch on the file descriptor.
Definition: session.c:570
ssh_get_issue_banner
char * ssh_get_issue_banner(ssh_session session)
Get the issue banner from the server.
Definition: client.c:646
ssh_string_fill
int ssh_string_fill(struct ssh_string_struct *s, const void *data, size_t len)
Fill a string with given data.
Definition: string.c:82
ssh_userauth_kbdint_getnprompts
int ssh_userauth_kbdint_getnprompts(ssh_session session)
Get the number of prompts (questions) the server has given.
Definition: auth.c:1584
ssh_event_add_fd
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:745
ssh_set_counters
void ssh_set_counters(ssh_session session, ssh_counter scounter, ssh_counter rcounter)
Set the session data counters.
Definition: session.c:923
ssh_options_copy
int ssh_options_copy(ssh_session src, ssh_session *dest)
Duplicate the options of a session structure.
Definition: options.c:64
ssh_userauth_kbdint_getinstruction
const char * ssh_userauth_kbdint_getinstruction(ssh_session session)
Get the "instruction" of the message block.
Definition: auth.c:1627
ssh_channel_open_session
int ssh_channel_open_session(ssh_channel channel)
Open a session channel (suited for a shell, not TCP forwarding).
Definition: channels.c:860
ssh_scp_request_get_size64
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:789
ssh_string_copy
struct ssh_string_struct * ssh_string_copy(struct ssh_string_struct *s)
Copy a string, return a newly allocated string.
Definition: string.c:216
ssh_string_get_char
const char * ssh_string_get_char(struct ssh_string_struct *s)
Get the the string as a C nul-terminated string.
Definition: string.c:155
ssh_userauth_kbdint_getnanswers
int ssh_userauth_kbdint_getnanswers(ssh_session session)
Get the number of answers the client has given.
Definition: auth.c:1690
ssh_set_blocking
void ssh_set_blocking(ssh_session session, int blocking)
Set the session in blocking/nonblocking mode.
Definition: session.c:448
ssh_channel_is_open
int ssh_channel_is_open(ssh_channel channel)
Check if the channel is open or not.
Definition: channels.c:1382
ssh_key_type_from_name
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:232
ssh_write_knownhost
int ssh_write_knownhost(ssh_session session)
Write the current server as known in the known hosts file.
Definition: known_hosts.c:526
ssh_channel_is_closed
int ssh_channel_is_closed(ssh_channel channel)
Check if the channel is closed or not.
Definition: channels.c:1398
ssh_userauth_kbdint_getanswer
const char * ssh_userauth_kbdint_getanswer(ssh_session session, unsigned int i)
Get the answer for a question from a message block.
Definition: auth.c:1705
ssh_key_free
void ssh_key_free(ssh_key key)
deallocate a SSH key
Definition: pki.c:178
SSH_LOG_WARNING
Only warnings.
Definition: libssh.h:283
SSH_LOG_FUNCTIONS
Every function path.
Definition: libssh.h:292
ssh_channel_get_session
ssh_session ssh_channel_get_session(ssh_channel channel)
Recover the session in which belongs a channel.
Definition: channels.c:2882
ssh_channel_poll_timeout
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:2841
ssh_pki_key_ecdsa_name
const char * ssh_pki_key_ecdsa_name(const ssh_key key)
returns the ECDSA key name ("ecdsa-sha2-nistp256" for example)
Definition: pki.c:110
ssh_scp_new
ssh_scp ssh_scp_new(ssh_session session, int mode, const char *location)
Create a new scp session.
Definition: scp.c:60
ssh_scp_request_get_filename
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:754
ssh_scp_write
int ssh_scp_write(ssh_scp scp, const void *buffer, size_t len)
Write into a remote scp file.
Definition: scp.c:437
ssh_event_new
ssh_event ssh_event_new(void)
Create a new event context.
Definition: poll.c:690
ssh_channel_poll
int ssh_channel_poll(ssh_channel channel, int is_stderr)
Polls a channel for data to read.
Definition: channels.c:2789
ssh_is_connected
int ssh_is_connected(ssh_session session)
Check if we are connected.
Definition: session.c:512
ssh_get_log_level
int ssh_get_log_level(void)
Get the log level of the library.
Definition: log.c:193
ssh_get_poll_flags
int ssh_get_poll_flags(ssh_session session)
Get poll flags for an external mainloop.
Definition: session.c:752
ssh_userauth_gssapi
int ssh_userauth_gssapi(ssh_session session)
Try to authenticate through the "gssapi-with-mic" method.
Definition: auth.c:1782
SSH_LOG_NOLOG
No logging at all.
Definition: libssh.h:280
ssh_channel_new
ssh_channel ssh_channel_new(ssh_session session)
Allocate a new channel.
Definition: channels.c:79
ssh_options_set
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:382
ssh_options_getopt
int ssh_options_getopt(ssh_session session, int *argcptr, char **argv)
Parse command line arguments.
Definition: options.c:1012
ssh_userauth_kbdint_getprompt
const char * ssh_userauth_kbdint_getprompt(ssh_session session, unsigned int i, char *echo)
Get a prompt from a message block.
Definition: auth.c:1662
ssh_userauth_kbdint_getname
const char * ssh_userauth_kbdint_getname(ssh_session session)
Get the "name" of the message block.
Definition: auth.c:1605
ssh_get_clientbanner
const char * ssh_get_clientbanner(ssh_session session)
get the client banner
Definition: session.c:311
ssh_event_remove_session
int ssh_event_remove_session(ssh_event event, ssh_session session)
Remove a session object from an event context.
Definition: poll.c:904
ssh_key_new
ssh_key ssh_key_new(void)
creates a new empty SSH key
Definition: pki.c:124
ssh_userauth_password
int ssh_userauth_password(ssh_session session, const char *username, const char *password)
Try to authenticate by password.
Definition: auth.c:1122
ssh_userauth_publickey_auto
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:906
ssh_userauth_kbdint_setanswer
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:1736
ssh_userauth_publickey
int ssh_userauth_publickey(ssh_session session, const char *username, const ssh_key privkey)
Authenticate with public/private key.
Definition: auth.c:550
ssh_get_cipher_out
const char * ssh_get_cipher_out(ssh_session session)
get the name of the output cipher for the given session.
Definition: session.c:385
ssh_select
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:451
ssh_get_fd
socket_t ssh_get_fd(ssh_session session)
Get the fd of a connection.
Definition: session.c:530
ssh_channel_change_pty_size
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:1707
ssh_connect
int ssh_connect(ssh_session session)
Connect to the ssh server.
Definition: client.c:528
ssh_key_type
enum ssh_keytypes_e ssh_key_type(const ssh_key key)
returns the type of a ssh key
Definition: pki.c:191
ssh_disconnect
void ssh_disconnect(ssh_session session)
Disconnect from a session (client or server).
Definition: client.c:686
ssh_userauth_none
int ssh_userauth_none(ssh_session session, const char *username)
Try to authenticate through the "none" method.
Definition: auth.c:354
ssh_string_free
void ssh_string_free(struct ssh_string_struct *s)
Deallocate a SSH string object.
Definition: string.c:272
ssh_channel_listen_forward
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:2165
ssh_channel_accept_x11
ssh_channel ssh_channel_accept_x11(ssh_channel channel, int timeout_ms)
Accept an X11 forwarding channel.
Definition: channels.c:1980
ssh_mkdir
int ssh_mkdir(const char *pathname, mode_t mode)
Attempts to create a directory with the given pathname.
Definition: misc.c:606
ssh_blocking_flush
int ssh_blocking_flush(ssh_session session, int timeout)
Blocking flush of the outgoing buffer.
Definition: session.c:487
ssh_key_cmp
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:303
ssh_channel_request_send_signal
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:2443
ssh_set_fd_towrite
void ssh_set_fd_towrite(ssh_session session)
Tell the session it may write to the file descriptor without blocking.
Definition: session.c:557
ssh_event_free
void ssh_event_free(ssh_event event)
Free an event context.
Definition: poll.c:950
SSH_LOG_PROTOCOL
High level protocol information.
Definition: libssh.h:286
ssh_channel_accept_forward
ssh_channel ssh_channel_accept_forward(ssh_session session, int timeout_ms, int *destination_port)
Accept an incoming TCP/IP forwarding channel and get information about incomming connection.
Definition: channels.c:2228
ssh_print_hexa
void ssh_print_hexa(const char *descr, const unsigned char *what, size_t len)
Print a buffer as colon separated hex string.
Definition: dh.c:1123
ssh_scp_request_get_warning
const char * ssh_scp_request_get_warning(ssh_scp scp)
Get the warning string from a scp handle.
Definition: scp.c:829
ssh_options_get_port
int ssh_options_get_port(ssh_session session, unsigned int *port_target)
This function can get ssh the ssh port.
Definition: options.c:884
ssh_scp_request_get_permissions
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:766
ssh_scp_request_get_size
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:779
ssh_string_data
void * ssh_string_data(struct ssh_string_struct *s)
Get the payload of the string.
Definition: string.c:259
ssh_channel_open_x11
int ssh_channel_open_x11(ssh_channel channel, const char *orig_addr, int orig_port)
Open a X11 channel.
Definition: channels.c:3267
ssh_scp_read
int ssh_scp_read(ssh_scp scp, void *buffer, size_t size)
Read from a remote scp file.
Definition: scp.c:703
ssh_basename
char * ssh_basename(const char *path)
basename - parse filename component.
Definition: misc.c:555
ssh_finalize
int ssh_finalize(void)
Finalize and cleanup all libssh and cryptographic data structures.
Definition: init.c:73
ssh_string_burn
void ssh_string_burn(struct ssh_string_struct *s)
Destroy the data in a string so it couldn&#39;t appear in a core dump.
Definition: string.c:244
ssh_channel_request_exec
int ssh_channel_request_exec(ssh_channel channel, const char *cmd)
Run a shell command without an interactive shell.
Definition: channels.c:2368
ssh_get_hmac_out
const char * ssh_get_hmac_out(ssh_session session)
get the name of the output HMAC algorithm for the given session.
Definition: session.c:416
ssh_channel_request_pty
int ssh_channel_request_pty(ssh_channel channel)
Request a PTY.
Definition: channels.c:1688
ssh_get_serverbanner
const char * ssh_get_serverbanner(ssh_session session)
get the server banner
Definition: session.c:326
ssh_silent_disconnect
void ssh_silent_disconnect(ssh_session session)
Disconnect impolitely from a remote host by closing the socket.
Definition: session.c:431
ssh_get_disconnect_message
const char * ssh_get_disconnect_message(ssh_session session)
Get the disconnect message from the server.
Definition: session.c:772
ssh_string_len
size_t ssh_string_len(struct ssh_string_struct *s)
Return the size of a SSH string.
Definition: string.c:131
ssh_channel_set_blocking
void ssh_channel_set_blocking(ssh_channel channel, int blocking)
Put the channel into blocking or nonblocking mode.
Definition: channels.c:1437
ssh_get_kex_algo
const char * ssh_get_kex_algo(ssh_session session)
get the name of the current key exchange algorithm.
Definition: session.c:340
ssh_message_free
void ssh_message_free(ssh_message msg)
Free a SSH message.
Definition: messages.c:502
ssh_message_subtype
int ssh_message_subtype(ssh_message msg)
Get the subtype of the message.
Definition: messages.c:478
ssh_new
ssh_session ssh_new(void)
Create a new ssh session.
Definition: session.c:58
ssh_get_publickey
int ssh_get_publickey(ssh_session session, ssh_key *key)
Get the server public key from a session.
Definition: dh.c:964
ssh_get_status
int ssh_get_status(ssh_session session)
Get session status.
Definition: session.c:714
ssh_channel_set_counter
void ssh_channel_set_counter(ssh_channel channel, ssh_counter counter)
Set the channel data counter.
Definition: channels.c:3155
ssh_channel_free
void ssh_channel_free(ssh_channel channel)
Close and free a channel.
Definition: channels.c:993
ssh_userauth_try_publickey
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:441
ssh_event_remove_fd
int ssh_event_remove_fd(ssh_event event, socket_t fd)
Remove a socket fd from an event context.
Definition: poll.c:858
ssh_scp_push_file64
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:317
ssh_scp_pull_request
int ssh_scp_pull_request(ssh_scp scp)
Wait for a scp request (file, directory).
Definition: scp.c:547
ssh_string_free_char
void ssh_string_free_char(char *s)
Deallocate a char string object.
Definition: string.c:204
ssh_is_server_known
int ssh_is_server_known(ssh_session session)
Check if the server is known.
Definition: known_hosts.c:406
ssh_send_ignore
int ssh_send_ignore(ssh_session session, const char *data)
Send a message that should be ignored.
Definition: session.c:832
ssh_is_blocking
int ssh_is_blocking(ssh_session session)
Return the blocking mode of libssh.
Definition: session.c:462
ssh_get_hexa
char * ssh_get_hexa(const unsigned char *what, size_t len)
Convert a buffer into a colon separated hex string.
Definition: dh.c:1089
ssh_get_publickey_hash
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: dh.c:1004
ssh_channel_get_exit_status
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:2918
ssh_pki_import_pubkey_file
int ssh_pki_import_pubkey_file(const char *filename, ssh_key *pkey)
Import a public key from the given filename.
Definition: pki.c:944
ssh_channel_cancel_forward
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:2247
ssh_userauth_agent
int ssh_userauth_agent(ssh_session session, const char *username)
Try to do public key authentication with ssh agent.
Definition: auth.c:775
ssh_get_hmac_in
const char * ssh_get_hmac_in(ssh_session session)
get the name of the input HMAC algorithm for the given session.
Definition: session.c:401
ssh_scp_push_file
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:372
ssh_pki_import_pubkey_base64
int ssh_pki_import_pubkey_base64(const char *b64_key, enum ssh_keytypes_e type, ssh_key *pkey)
Import a base64 formated public key from a memory c-string.
Definition: pki.c:838
ssh_scp_push_directory
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:227
ssh_channel_read
int ssh_channel_read(ssh_channel channel, void *dest, uint32_t count, int is_stderr)
Reads data from a channel.
Definition: channels.c:2599
ssh_pki_import_privkey_base64
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 formated key from a memory c-string
Definition: pki.c:398
ssh_free
void ssh_free(ssh_session session)
Deallocate a SSH session handle.
Definition: session.c:181
ssh_scp_close
int ssh_scp_close(ssh_scp scp)
Close the scp channel.
Definition: scp.c:161
ssh_channel_read_nonblocking
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:2737
ssh_dirname
char * ssh_dirname(const char *path)
Parse directory component.
Definition: misc.c:500
ssh_get_error_code
int ssh_get_error_code(void *error)
Retrieve the error code from the last error.
Definition: error.c:131
ssh_pki_import_privkey_file
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 key from a file.
Definition: pki.c:461