Server Wait On Clients System - API Documentation  v1.6.4
Server Wait On Clients System.
ssh.c File Reference

SSH connection processing functions. More...

#include <libssh/libssh.h>
#include <netinet/in.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <sys/socket.h>
#include <syslog.h>
#include <unistd.h>
#include <libmgec/mge-errno.h>
#include <libmgec/mge-memory.h>
#include <swoc/libswoccommon.h>
Include dependency graph for ssh.c:

Functions

static int verify_knownhost (void)
 
static int try_auth_methods_seq (void)
 
static int authenticate_kbdint (void)
 
static int authenticate_password (void)
 
static int direct_forwarding (void)
 
static void * relay_data (__attribute__((unused)) void *arg)
 
int open_ssh_tunnel (void)
 Establish SSH connection. More...
 
int close_ssh_tunnel (void)
 Disconnect and close an SSH session. More...
 

Variables

static ssh_session ssh_sess
 
static ssh_channel fwd_chan
 
static int ssh_sock
 
static pthread_t relay_thread
 
static const int relay_data_success = 0
 
static const int relay_data_failure = -MGE_SSH
 

Detailed Description

SSH connection processing functions.

Covers tunnel creation and destruction including all authentication. Creates a seperate thread for data relay through the tunnel.

Author
Copyright (C) 2017-2019, 2021, 2022 Mark Grant

Released under the GPLv3 only.
SPDX-License-Identifier: GPL-3.0-only

Version
v1.0.12 ==== 17/09/2022

Function Documentation

◆ authenticate_kbdint()

static int authenticate_kbdint ( void  )
static

◆ authenticate_password()

static int authenticate_password ( void  )
static

◆ close_ssh_tunnel()

int close_ssh_tunnel ( void  )

Disconnect and close an SSH session.

Join data relay thread, free channel and disconnect session. On error mge_errno will be set.

Returns
0 on success, < zero on failure.

◆ direct_forwarding()

static int direct_forwarding ( void  )
static

◆ open_ssh_tunnel()

int open_ssh_tunnel ( void  )

Establish SSH connection.

Create session, connect to server, create a tunnel and spawn a thread to relay data through the tunnel. On error mge_errno will be set.

Returns
0 on success, < zero on error.

◆ relay_data()

static void * relay_data ( __attribute__((unused)) void *  arg)
static

◆ try_auth_methods_seq()

static int try_auth_methods_seq ( void  )
static

◆ verify_knownhost()

static int verify_knownhost ( void  )
static

Variable Documentation

◆ fwd_chan

ssh_channel fwd_chan
static

◆ relay_data_failure

const int relay_data_failure = -MGE_SSH
static

◆ relay_data_success

const int relay_data_success = 0
static

◆ relay_thread

pthread_t relay_thread
static

◆ ssh_sess

ssh_session ssh_sess
static

◆ ssh_sock

int ssh_sock
static