2016-03-01 13:13:41 +00:00
|
|
|
/* ssh-base.h
|
|
|
|
* ssh-base has base utility functions to connect to hosts via ssh
|
|
|
|
*
|
|
|
|
* Copyright 2016, Dario Lombardo
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-02-07 11:26:45 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2016-03-01 13:13:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SSHBASE_H__
|
|
|
|
#define __SSHBASE_H__
|
|
|
|
|
|
|
|
#include <libssh/libssh.h>
|
|
|
|
|
2016-08-31 08:14:33 +00:00
|
|
|
#include <glib.h>
|
|
|
|
|
2016-08-05 20:20:28 +00:00
|
|
|
#ifndef STDERR_FILENO
|
|
|
|
#define STDERR_FILENO 2
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef STDOUT_FILENO
|
|
|
|
#define STDOUT_FILENO 1
|
|
|
|
#endif
|
|
|
|
|
2016-03-04 09:53:56 +00:00
|
|
|
#define SSH_BASE_OPTIONS \
|
|
|
|
{ "remote-host", required_argument, NULL, OPT_REMOTE_HOST}, \
|
|
|
|
{ "remote-port", required_argument, NULL, OPT_REMOTE_PORT}, \
|
|
|
|
{ "remote-username", required_argument, NULL, OPT_REMOTE_USERNAME}, \
|
|
|
|
{ "remote-password", required_argument, NULL, OPT_REMOTE_PASSWORD}, \
|
|
|
|
{ "remote-interface", required_argument, NULL, OPT_REMOTE_INTERFACE}, \
|
|
|
|
{ "remote-filter", required_argument, NULL, OPT_REMOTE_FILTER}, \
|
|
|
|
{ "remote-count", required_argument, NULL, OPT_REMOTE_COUNT}, \
|
|
|
|
{ "sshkey", required_argument, NULL, OPT_SSHKEY}, \
|
2018-11-03 14:15:43 +00:00
|
|
|
{ "sshkey-passphrase", required_argument, NULL, OPT_SSHKEY_PASSPHRASE}, \
|
|
|
|
{ "proxycommand", required_argument, NULL, OPT_PROXYCOMMAND}
|
2016-03-04 09:53:56 +00:00
|
|
|
|
2018-11-09 22:10:46 +00:00
|
|
|
typedef struct _ssh_params {
|
|
|
|
gchar* host;
|
|
|
|
guint16 port;
|
|
|
|
gchar* username;
|
|
|
|
gchar* password;
|
|
|
|
gchar* sshkey_path;
|
|
|
|
gchar* sshkey_passphrase;
|
|
|
|
gchar* proxycommand;
|
2018-11-10 20:15:58 +00:00
|
|
|
gboolean debug;
|
2018-11-09 22:10:46 +00:00
|
|
|
} ssh_params_t;
|
|
|
|
|
2016-03-01 13:13:41 +00:00
|
|
|
/* Create a ssh connection using all the possible authentication menthods */
|
2018-11-09 22:10:46 +00:00
|
|
|
ssh_session create_ssh_connection(const ssh_params_t* ssh_params, char** err_info);
|
2016-03-01 13:13:41 +00:00
|
|
|
|
2016-03-04 09:53:56 +00:00
|
|
|
/* Write a formatted message in the channel */
|
|
|
|
int ssh_channel_printf(ssh_channel channel, const char* fmt, ...);
|
|
|
|
|
2016-03-01 13:13:41 +00:00
|
|
|
/* Clean the current ssh session and channel. */
|
|
|
|
void ssh_cleanup(ssh_session* sshs, ssh_channel* channel);
|
|
|
|
|
2018-11-09 22:10:46 +00:00
|
|
|
/* Init the ssh_params_t structure */
|
|
|
|
ssh_params_t* ssh_params_new(void);
|
|
|
|
|
|
|
|
/* Clean the ssh params */
|
|
|
|
void ssh_params_free(ssh_params_t* ssh_params);
|
|
|
|
|
2016-03-01 13:13:41 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: t
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
|
|
|
* :indentSize=8:tabSize=8:noTabs=false:
|
2016-05-03 10:15:12 +00:00
|
|
|
*/
|