libssh: /build/libssh/src/libssh-0.12.0/include/libssh/libsshpp.hpp Source File

libssh 0.12.0 The SSH library

Loading...
Searching...
No Matches
libsshpp.hpp
1/*
2 * This file is part of the SSH Library
3 *
4 * Copyright (c) 2010 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 LIBSSHPP_HPP_
22#define LIBSSHPP_HPP_
23
50
51/* do not use deprecated functions */
52#define LIBSSH_LEGACY_0_4
53
54#include <libssh/libssh.h>
55#include <libssh/server.h>
56#include <stdlib.h>
57#include <stdarg.h>
58#include <stdio.h>
59#include <string>
60
61namespace ssh {
62
63class Channel;
68#ifndef SSH_NO_CPP_EXCEPTIONS
69
74 class SshException{
75public:
76 SshException(ssh_session csession){
77 code=ssh_get_error_code(csession);
78 description=std::string(ssh_get_error(csession));
79 }
80 SshException(const SshException &e){
81 code=e.code;
82 description=e.description;
83 }
89 int getCode(){
90 return code;
91 }
92
96 std::string getError(){
97 return description;
98 }
99private:
100 int code;
101 std::string description;
102};
103
107#define ssh_throw(x) if((x)==SSH_ERROR) throw SshException(getCSession())
108#define ssh_throw_null(CSession,x) if((x)==NULL) throw SshException(CSession)
109#define void_throwable void
110#define return_throwable return
111
112#else
113
114/* No exception at all. All functions will return an error code instead
115 * of an exception
116 */
117#define ssh_throw(x) if((x)==SSH_ERROR) return SSH_ERROR
118#define ssh_throw_null(CSession,x) if((x)==NULL) return NULL
119#define void_throwable int
120#define return_throwable return SSH_OK
121#endif
122
126 class Session {
127 friend class Channel;
128public:
129 Session(){
130 c_session=ssh_new();
131 }
132 ~Session(){
133 ssh_free(c_session);
134 c_session=NULL;
135 }
142 void_throwable setOption(enum ssh_options_e type, const char *option){
143 ssh_throw(ssh_options_set(c_session,type,option));
144 return_throwable;
145 }
146
152 void_throwable setOption(enum ssh_options_e type, long int option){
153 ssh_throw(ssh_options_set(c_session,type,&option));
154 return_throwable;
155 }
156
162 void_throwable setOption(enum ssh_options_e type, void *option){
163 ssh_throw(ssh_options_set(c_session,type,option));
164 return_throwable;
165 }
166
170 void_throwable connect(){
171 int ret=ssh_connect(c_session);
172 ssh_throw(ret);
173 return_throwable;
174 }
175
180 int userauthPublickeyAuto(void){
181 int ret=ssh_userauth_publickey_auto(c_session, NULL, NULL);
182 ssh_throw(ret);
183 return ret;
184 }
185
192 int userauthNone(){
193 int ret=ssh_userauth_none(c_session,NULL);
194 ssh_throw(ret);
195 return ret;
196 }
197
214 int userauthKbdint(const char* username, const char* submethods){
215 int ret = ssh_userauth_kbdint(c_session, username, submethods);
216 ssh_throw(ret);
217 return ret;
218 }
219
224 int userauthKbdintGetNPrompts(){
225 return ssh_userauth_kbdint_getnprompts(c_session);
226 }
227
244 int userauthKbdintSetAnswer(unsigned int index, const char *answer)
245 {
246 int ret = ssh_userauth_kbdint_setanswer(c_session, index, answer);
247 ssh_throw(ret);
248 return ret;
249 }
250
251
252
259 int userauthPassword(const char *password){
260 int ret=ssh_userauth_password(c_session,NULL,password);
261 ssh_throw(ret);
262 return ret;
263 }
264
271 int userauthTryPublickey(ssh_key pubkey){
272 int ret=ssh_userauth_try_publickey(c_session, NULL, pubkey);
273 ssh_throw(ret);
274 return ret;
275 }
276
282 int userauthPublickey(ssh_key privkey){
283 int ret=ssh_userauth_publickey(c_session, NULL, privkey);
284 ssh_throw(ret);
285 return ret;
286 }
287
293 int getAuthList(){
294 int ret=ssh_userauth_list(c_session, NULL);
295 ssh_throw(ret);
296 return ret;
297 }
298
301 void disconnect(){
302 ssh_disconnect(c_session);
303 }
304
308 const char *getDisconnectMessage(){
309 const char *msg=ssh_get_disconnect_message(c_session);
310 return msg;
311 }
312
315 const char *getError(){
316 return ssh_get_error(c_session);
317 }
321 int getErrorCode(){
322 return ssh_get_error_code(c_session);
323 }
330 socket_t getSocket(){
331 return ssh_get_fd(c_session);
332 }
333
337 std::string getIssueBanner(){
338 char *banner = ssh_get_issue_banner(c_session);
339 std::string ret = "";
340 if (banner != NULL) {
341 ret = std::string(banner);
342 ::free(banner);
343 }
344 return ret;
345 }
346
350 int getOpensshVersion(){
351 return ssh_get_openssh_version(c_session);
352 }
353
357 int getVersion(){
358 return ssh_get_version(c_session);
359 }
360
366 int isServerKnown(){
367 int state = ssh_session_is_known_server(c_session);
368 ssh_throw(state);
369 return state;
370 }
371 void log(int priority, const char *format, ...){
372 va_list va;
373
374 va_start(va, format);
375 ssh_vlog(priority, "libsshpp", format, &va);
376 va_end(va);
377 }
378
383 void_throwable optionsCopy(const Session &source){
384 ssh_throw(ssh_options_copy(source.c_session,&c_session));
385 return_throwable;
386 }
387
392 void_throwable optionsParseConfig(const char *file){
393 ssh_throw(ssh_options_parse_config(c_session,file));
394 return_throwable;
395 }
396
399 void silentDisconnect(){
400 ssh_silent_disconnect(c_session);
401 }
402
407 int writeKnownhost(){
408 int ret = ssh_session_update_known_hosts(c_session);
409 ssh_throw(ret);
410 return ret;
411 }
412
421 inline Channel *acceptForward(int timeout_ms);
422 /* implemented outside the class due Channel references */
423
424 void_throwable cancelForward(const char *address, int port){
425 int err=ssh_channel_cancel_forward(c_session, address, port);
426 ssh_throw(err);
427 return_throwable;
428 }
429
430 void_throwable listenForward(const char *address, int port,
431 int &boundport){
432 int err=ssh_channel_listen_forward(c_session, address, port, &boundport);
433 ssh_throw(err);
434 return_throwable;
435 }
436
437 ssh_session getCSession(){
438 return c_session;
439 }
440
441protected:
442 ssh_session c_session;
443
444private:
445 /* No copy constructor, no = operator */
446 Session(const Session &);
447 Session& operator=(const Session &);
448};
449
454 class Channel {
455 friend class Session;
456public:
457 Channel(Session &ssh_session){
458 channel = ssh_channel_new(ssh_session.getCSession());
459 this->session = &ssh_session;
460 }
461 ~Channel(){
462 ssh_channel_free(channel);
463 channel=NULL;
464 }
465
474 Channel *acceptX11(int timeout_ms){
475 ssh_channel x11chan = ssh_channel_accept_x11(channel,timeout_ms);
476 ssh_throw_null(getCSession(),x11chan);
477 Channel *newchan = new Channel(getSession(),x11chan);
478 return newchan;
479 }
480
486 void_throwable changePtySize(int cols, int rows){
487 int err=ssh_channel_change_pty_size(channel,cols,rows);
488 ssh_throw(err);
489 return_throwable;
490 }
491
496 void_throwable close(){
497 ssh_throw(ssh_channel_close(channel));
498 return_throwable;
499 }
500
501 /*
502 * @deprecated Please use getExitState()
503 */
504 int getExitStatus() {
505 uint32_t exit_status = (uint32_t)-1;
506 ssh_channel_get_exit_state(channel, &exit_status, NULL, NULL);
507 return exit_status;
508 }
509 void_throwable getExitState(uint32_t & pexit_code,
510 char **pexit_signal,
511 int & pcore_dumped) {
512 ssh_throw(ssh_channel_get_exit_state(channel,
513 &pexit_code,
514 pexit_signal,
515 &pcore_dumped));
516 return_throwable;
517 }
518 Session &getSession(){
519 return *session;
520 }
524 bool isClosed(){
525 return ssh_channel_is_closed(channel) != 0;
526 }
527
530 bool isEof(){
531 return ssh_channel_is_eof(channel) != 0;
532 }
533
536 bool isOpen(){
537 return ssh_channel_is_open(channel) != 0;
538 }
539 int openForward(const char *remotehost, int remoteport,
540 const char *sourcehost, int localport=0){
541 int err=ssh_channel_open_forward(channel,remotehost,remoteport,
542 sourcehost, localport);
543 ssh_throw(err);
544 return err;
545 }
546 /* TODO: completely remove this ? */
547 void_throwable openSession(){
548 int err=ssh_channel_open_session(channel);
549 ssh_throw(err);
550 return_throwable;
551 }
552 int poll(bool is_stderr=false){
553 int err=ssh_channel_poll(channel,is_stderr);
554 ssh_throw(err);
555 return err;
556 }
557 int read(void *dest, size_t count){
558 int err;
559 /* handle int overflow */
560 if(count > 0x7fffffff)
561 count = 0x7fffffff;
562 err=ssh_channel_read_timeout(channel,dest,count,false,-1);
563 ssh_throw(err);
564 return err;
565 }
566 int read(void *dest, size_t count, int timeout){
567 int err;
568 /* handle int overflow */
569 if(count > 0x7fffffff)
570 count = 0x7fffffff;
571 err=ssh_channel_read_timeout(channel,dest,count,false,timeout);
572 ssh_throw(err);
573 return err;
574 }
575 int read(void *dest, size_t count, bool is_stderr=false, int timeout=-1){
576 int err;
577 /* handle int overflow */
578 if(count > 0x7fffffff)
579 count = 0x7fffffff;
580 err=ssh_channel_read_timeout(channel,dest,count,is_stderr,timeout);
581 ssh_throw(err);
582 return err;
583 }
584 int readNonblocking(void *dest, size_t count, bool is_stderr=false){
585 int err;
586 /* handle int overflow */
587 if(count > 0x7fffffff)
588 count = 0x7fffffff;
589 err=ssh_channel_read_nonblocking(channel,dest,count,is_stderr);
590 ssh_throw(err);
591 return err;
592 }
593 void_throwable requestEnv(const char *name, const char *value){
594 int err=ssh_channel_request_env(channel,name,value);
595 ssh_throw(err);
596 return_throwable;
597 }
598
599 void_throwable requestExec(const char *cmd){
600 int err=ssh_channel_request_exec(channel,cmd);
601 ssh_throw(err);
602 return_throwable;
603 }
604 void_throwable requestPty(const char *term=NULL, int cols=0, int rows=0,
605 const unsigned char* modes=NULL, size_t modes_len=0){
606 int err;
607 if(term != NULL && cols != 0 && rows != 0 && modes != NULL)
608 err=ssh_channel_request_pty_size_modes(channel,term,cols,rows,modes,modes_len);
609 else if(term != NULL && cols != 0 && rows != 0)
610 err=ssh_channel_request_pty_size(channel,term,cols,rows);
611 else
612 err=ssh_channel_request_pty(channel);
613 ssh_throw(err);
614 return_throwable;
615 }
616
617 void_throwable requestShell(){
618 int err=ssh_channel_request_shell(channel);
619 ssh_throw(err);
620 return_throwable;
621 }
622 void_throwable requestSendSignal(const char *signum){
623 int err=ssh_channel_request_send_signal(channel, signum);
624 ssh_throw(err);
625 return_throwable;
626 }
627 void_throwable requestSubsystem(const char *subsystem){
628 int err=ssh_channel_request_subsystem(channel,subsystem);
629 ssh_throw(err);
630 return_throwable;
631 }
632 int requestX11(bool single_connection,
633 const char *protocol, const char *cookie, int screen_number){
634 int err=ssh_channel_request_x11(channel,single_connection,
635 protocol, cookie, screen_number);
636 ssh_throw(err);
637 return err;
638 }
639 void_throwable sendEof(){
640 int err=ssh_channel_send_eof(channel);
641 ssh_throw(err);
642 return_throwable;
643 }
653 int write(const void *data, size_t len, bool is_stderr=false){
654 int ret;
655 if(is_stderr){
656 ret=ssh_channel_write_stderr(channel,data,len);
657 } else {
658 ret=ssh_channel_write(channel,data,len);
659 }
660 ssh_throw(ret);
661 return ret;
662 }
663
664 ssh_session getCSession(){
665 return session->getCSession();
666 }
667
668 ssh_channel getCChannel() {
669 return channel;
670 }
671
672protected:
673 Session *session;
674 ssh_channel channel;
675
676private:
677 Channel (Session &ssh_session, ssh_channel c_channel){
678 this->channel=c_channel;
679 this->session = &ssh_session;
680 }
681 /* No copy and no = operator */
682 Channel(const Channel &);
683 Channel &operator=(const Channel &);
684};
685
686
687 inline Channel *Session::acceptForward(int timeout_ms){
688 ssh_channel forward =
689 ssh_channel_open_forward_port(c_session, timeout_ms, NULL, NULL, NULL);
690 ssh_throw_null(c_session,forward);
691 Channel *newchan = new Channel(*this,forward);
692 return newchan;
693 }
694
695} // namespace ssh
696
698#endif /* LIBSSHPP_HPP_ */
ssh::Channel
the ssh::Channel class describes the state of an SSH channel.
Definition libsshpp.hpp:454
ssh::Channel::write
int write(const void *data, size_t len, bool is_stderr=false)
Writes on a channel.
Definition libsshpp.hpp:653
ssh::Channel::close
void_throwable close()
closes a channel
Definition libsshpp.hpp:496
ssh::Channel::isClosed
bool isClosed()
returns true if channel is in closed state
Definition libsshpp.hpp:524
ssh::Channel::changePtySize
void_throwable changePtySize(int cols, int rows)
change the size of a pseudoterminal
Definition libsshpp.hpp:486
ssh::Channel::isEof
bool isEof()
returns true if channel is in EOF state
Definition libsshpp.hpp:530
ssh::Channel::isOpen
bool isOpen()
returns true if channel is in open state
Definition libsshpp.hpp:536
ssh::Channel::acceptX11
Channel * acceptX11(int timeout_ms)
accept an incoming X11 connection
Definition libsshpp.hpp:474
ssh::Session::getAuthList
int getAuthList()
Returns the available authentication methods from the server.
Definition libsshpp.hpp:293
ssh::Session::isServerKnown
int isServerKnown()
verifies that the server is known
Definition libsshpp.hpp:366
ssh::Session::userauthKbdintGetNPrompts
int userauthKbdintGetNPrompts()
Get the number of prompts (questions) the server has given.
Definition libsshpp.hpp:224
ssh::Session::userauthKbdint
int userauthKbdint(const char *username, const char *submethods)
Authenticate through the "keyboard-interactive" method.
Definition libsshpp.hpp:214
ssh::Session::silentDisconnect
void silentDisconnect()
silently disconnect from remote host
Definition libsshpp.hpp:399
ssh::Session::setOption
void_throwable setOption(enum ssh_options_e type, long int option)
sets an SSH session options
Definition libsshpp.hpp:152
ssh::Session::getSocket
socket_t getSocket()
returns the file descriptor used for the communication
Definition libsshpp.hpp:330
ssh::Session::setOption
void_throwable setOption(enum ssh_options_e type, void *option)
sets an SSH session options
Definition libsshpp.hpp:162
ssh::Session::setOption
void_throwable setOption(enum ssh_options_e type, const char *option)
sets an SSH session options
Definition libsshpp.hpp:142
ssh::Session::getVersion
int getVersion()
returns the version of the SSH protocol being used
Definition libsshpp.hpp:357
ssh::Session::getDisconnectMessage
const char * getDisconnectMessage()
Returns the disconnect message from the server, if any.
Definition libsshpp.hpp:308
ssh::Session::userauthPublickeyAuto
int userauthPublickeyAuto(void)
Authenticates automatically using public key.
Definition libsshpp.hpp:180
ssh::Session::acceptForward
Channel * acceptForward(int timeout_ms)
accept an incoming forward connection
Definition libsshpp.hpp:687
ssh::Session::connect
void_throwable connect()
connects to the remote host
Definition libsshpp.hpp:170
ssh::Session::userauthPublickey
int userauthPublickey(ssh_key privkey)
Authenticates using the publickey method.
Definition libsshpp.hpp:282
ssh::Session::userauthKbdintSetAnswer
int userauthKbdintSetAnswer(unsigned int index, const char *answer)
Set the answer for a question from a message block.
Definition libsshpp.hpp:244
ssh::Session::userauthNone
int userauthNone()
Authenticates using the "none" method. Prefer using autopubkey if possible.
Definition libsshpp.hpp:192
ssh::Session::getIssueBanner
std::string getIssueBanner()
gets the Issue banner from the ssh server
Definition libsshpp.hpp:337
ssh::Session::getOpensshVersion
int getOpensshVersion()
returns the OpenSSH version (server) if possible
Definition libsshpp.hpp:350
ssh::Session::disconnect
void disconnect()
Disconnects from the SSH server and closes connection.
Definition libsshpp.hpp:301
ssh::Session::userauthPassword
int userauthPassword(const char *password)
Authenticates using the password method.
Definition libsshpp.hpp:259
ssh::Session::optionsCopy
void_throwable optionsCopy(const Session &source)
copies options from a session to another
Definition libsshpp.hpp:383
ssh::Session::writeKnownhost
int writeKnownhost()
Writes the known host file with current host key.
Definition libsshpp.hpp:407
ssh::Session::optionsParseConfig
void_throwable optionsParseConfig(const char *file)
parses a configuration file for options
Definition libsshpp.hpp:392
ssh::Session::userauthTryPublickey
int userauthTryPublickey(ssh_key pubkey)
Try to authenticate using the publickey method.
Definition libsshpp.hpp:271
ssh::SshException::getCode
int getCode()
returns the Error code
Definition libsshpp.hpp:89
ssh::SshException::getError
std::string getError()
returns the error message of the last exception
Definition libsshpp.hpp:96
ssh_userauth_list
LIBSSH_API int ssh_userauth_list(ssh_session session, const char *username)
Get available authentication methods from the server.
Definition auth.c:392
ssh_userauth_password
LIBSSH_API int ssh_userauth_password(ssh_session session, const char *username, const char *password)
Try to authenticate by password.
Definition auth.c:1736
ssh_userauth_publickey_auto
LIBSSH_API int ssh_userauth_publickey_auto(ssh_session session, const char *username, const char *passphrase)
Tries to automatically authenticate with public key and "none".
Definition auth.c:1387
ssh_userauth_none
LIBSSH_API int ssh_userauth_none(ssh_session session, const char *username)
Try to authenticate through the "none" method.
Definition auth.c:422
ssh_userauth_try_publickey
LIBSSH_API int ssh_userauth_try_publickey(ssh_session session, const char *username, const ssh_key pubkey)
Try to authenticate with the given public key.
Definition auth.c:610
ssh_userauth_kbdint
LIBSSH_API int ssh_userauth_kbdint(ssh_session session, const char *user, const char *submethods)
Try to authenticate through the "keyboard-interactive" method.
Definition auth.c:2166
ssh_userauth_kbdint_setanswer
LIBSSH_API int ssh_userauth_kbdint_setanswer(ssh_session session, unsigned int i, const char *answer)
Set the answer for a question from a message block.
Definition auth.c:2373
ssh_userauth_publickey
LIBSSH_API int ssh_userauth_publickey(ssh_session session, const char *username, const ssh_key privkey)
Authenticate with public/private key or certificate.
Definition auth.c:739
ssh_userauth_kbdint_getnprompts
LIBSSH_API int ssh_userauth_kbdint_getnprompts(ssh_session session)
Get the number of prompts (questions) the server has given.
Definition auth.c:2210
ssh_channel_request_subsystem
LIBSSH_API int ssh_channel_request_subsystem(ssh_channel channel, const char *subsystem)
Request a subsystem (for example "sftp").
Definition channels.c:2182
ssh_channel_send_eof
LIBSSH_API int ssh_channel_send_eof(ssh_channel channel)
Send an end of file on the channel.
Definition channels.c:1382
ssh_channel_poll
LIBSSH_API int ssh_channel_poll(ssh_channel channel, int is_stderr)
Polls a channel for data to read.
Definition channels.c:3320
ssh_channel_get_exit_state
LIBSSH_API int ssh_channel_get_exit_state(ssh_channel channel, uint32_t *pexit_code, char **pexit_signal, int *pcore_dumped)
Get the exit state of the channel (error code from the executed instruction or signal).
Definition channels.c:3485
ssh_channel_close
LIBSSH_API int ssh_channel_close(ssh_channel channel)
Close a channel.
Definition channels.c:1443
ssh_channel_request_pty_size_modes
LIBSSH_API int ssh_channel_request_pty_size_modes(ssh_channel channel, const char *term, int cols, int rows, const unsigned char *modes, size_t modes_len)
Request a pty with a specific type and size.
Definition channels.c:2004
ssh_channel_read_timeout
LIBSSH_API int ssh_channel_read_timeout(ssh_channel channel, void *dest, uint32_t count, int is_stderr, int timeout_ms)
Reads data from a channel.
Definition channels.c:3149
ssh_channel_request_pty
LIBSSH_API int ssh_channel_request_pty(ssh_channel channel)
Request a PTY.
Definition channels.c:2099
ssh_channel_cancel_forward
LIBSSH_API int ssh_channel_cancel_forward(ssh_session session, const char *address, int port)
Sends the "cancel-tcpip-forward" global request to ask the server to cancel the tcpip-forward request...
Definition channels.c:2729
ssh_channel_open_forward_port
LIBSSH_API ssh_channel ssh_channel_open_forward_port(ssh_session session, int timeout_ms, int *destination_port, char **originator, int *originator_port)
Accept an incoming TCP/IP forwarding channel and get information about incoming connection.
Definition channels.c:2710
ssh_channel_accept_x11
LIBSSH_API ssh_channel ssh_channel_accept_x11(ssh_channel channel, int timeout_ms)
Accept an X11 forwarding channel.
Definition channels.c:2410
ssh_channel_request_exec
LIBSSH_API int ssh_channel_request_exec(ssh_channel channel, const char *cmd)
Run a shell command without an interactive shell.
Definition channels.c:2858
ssh_channel_write
LIBSSH_API int ssh_channel_write(ssh_channel channel, const void *data, uint32_t len)
Blocking write on a channel.
Definition channels.c:1725
ssh_channel_listen_forward
LIBSSH_API int ssh_channel_listen_forward(ssh_session session, const char *address, int port, int *bound_port)
Sends the "tcpip-forward" global request to ask the server to begin listening for inbound connections...
Definition channels.c:2620
ssh_channel_request_env
LIBSSH_API int ssh_channel_request_env(ssh_channel channel, const char *name, const char *value)
Set environment variables.
Definition channels.c:2781
ssh_channel_write_stderr
LIBSSH_API int ssh_channel_write_stderr(ssh_channel channel, const void *data, uint32_t len)
Blocking write on a channel stderr.
Definition channels.c:3835
ssh_channel_request_send_signal
LIBSSH_API int ssh_channel_request_send_signal(ssh_channel channel, const char *signum)
Send a signal to remote process (as described in RFC 4254, section 6.9).
Definition channels.c:2924
ssh_channel_is_open
LIBSSH_API int ssh_channel_is_open(ssh_channel channel)
Check if the channel is open or not.
Definition channels.c:1739
ssh_channel_read_nonblocking
LIBSSH_API int ssh_channel_read_nonblocking(ssh_channel channel, void *dest, uint32_t count, int is_stderr)
Do a nonblocking read on the channel.
Definition channels.c:3259
ssh_channel_is_closed
LIBSSH_API int ssh_channel_is_closed(ssh_channel channel)
Check if the channel is closed or not.
Definition channels.c:1756
ssh_channel_is_eof
LIBSSH_API int ssh_channel_is_eof(ssh_channel channel)
Check if remote has sent an EOF.
Definition channels.c:1771
ssh_channel_request_pty_size
LIBSSH_API int ssh_channel_request_pty_size(ssh_channel channel, const char *term, int cols, int rows)
Request a PTY with a specific size using current TTY modes.
Definition channels.c:2070
ssh_channel_free
LIBSSH_API void ssh_channel_free(ssh_channel channel)
Close and free a channel.
Definition channels.c:1275
ssh_channel_new
LIBSSH_API ssh_channel ssh_channel_new(ssh_session session)
Allocate a new channel.
Definition channels.c:90
ssh_channel_request_x11
LIBSSH_API int ssh_channel_request_x11(ssh_channel channel, int single_connection, const char *protocol, const char *cookie, int screen_number)
Sends the "x11-req" channel request over an existing session channel.
Definition channels.c:2286
ssh_channel_open_forward
LIBSSH_API int ssh_channel_open_forward(ssh_channel channel, const char *remotehost, int remoteport, const char *sourcehost, int localport)
Open a TCP/IP forwarding channel.
Definition channels.c:1138
ssh_channel_request_shell
LIBSSH_API int ssh_channel_request_shell(ssh_channel channel)
Request a shell.
Definition channels.c:2159
ssh_channel_open_session
LIBSSH_API int ssh_channel_open_session(ssh_channel channel)
Open a session channel (suited for a shell, not TCP forwarding).
Definition channels.c:1072
ssh_channel_change_pty_size
LIBSSH_API int ssh_channel_change_pty_size(ssh_channel channel, int cols, int rows)
Change the size of the terminal associated to a channel.
Definition channels.c:2119
ssh_get_error_code
LIBSSH_API int ssh_get_error_code(void *error)
Retrieve the error code from the last error.
Definition error.c:148
ssh_get_error
LIBSSH_API const char * ssh_get_error(void *error)
Retrieve the error text message from the last error.
Definition error.c:128
ssh_connect
LIBSSH_API int ssh_connect(ssh_session session)
Connect to the ssh server.
Definition client.c:555
ssh_get_disconnect_message
LIBSSH_API const char * ssh_get_disconnect_message(ssh_session session)
Get the disconnect message from the server.
Definition session.c:976
ssh_disconnect
LIBSSH_API void ssh_disconnect(ssh_session session)
Disconnect from a session (client or server).
Definition client.c:812
ssh_get_issue_banner
LIBSSH_API char * ssh_get_issue_banner(ssh_session session)
Get the issue banner from the server.
Definition client.c:710
ssh_options_set
LIBSSH_API int ssh_options_set(ssh_session session, enum ssh_options_e type, const void *value)
This function can set all possible ssh options.
Definition options.c:698
ssh_options_parse_config
LIBSSH_API int ssh_options_parse_config(ssh_session session, const char *filename)
Parse the ssh config file.
Definition options.c:1974
ssh_get_version
LIBSSH_API int ssh_get_version(ssh_session session)
Get the protocol version of the session.
Definition session.c:1001
ssh_session_update_known_hosts
LIBSSH_API int ssh_session_update_known_hosts(ssh_session session)
Adds the currently connected server to the user known_hosts file.
Definition knownhosts.c:1016
ssh_new
LIBSSH_API ssh_session ssh_new(void)
Create a new ssh session.
Definition session.c:64
ssh_get_openssh_version
LIBSSH_API int ssh_get_openssh_version(ssh_session session)
Get the version of the OpenSSH server, if it is not an OpenSSH server then 0 will be returned.
Definition client.c:737
ssh_session_is_known_server
LIBSSH_API enum ssh_known_hosts_e ssh_session_is_known_server(ssh_session session)
Check if the servers public key for the connected session is known.
Definition knownhosts.c:1304
ssh_silent_disconnect
LIBSSH_API void ssh_silent_disconnect(ssh_session session)
Disconnect impolitely from a remote host by closing the socket.
Definition session.c:614
ssh_free
LIBSSH_API void ssh_free(ssh_session session)
Deallocate a SSH session handle.
Definition session.c:250
ssh_options_copy
LIBSSH_API int ssh_options_copy(ssh_session src, ssh_session *dest)
Duplicate the options of a session structure.
Definition options.c:76
ssh_get_fd
LIBSSH_API socket_t ssh_get_fd(ssh_session session)
Get the fd of a connection.
Definition session.c:714