Add new wsssh application - SSH wrapper with ProxyCommand support

- Create wsssh.h header file with configuration structures and function declarations
- Implement wsssh.c with comprehensive SSH wrapper functionality:
  * Parse command line arguments (--help, --clientid, --wssshd-host, --wssshd-port, --debug, --tunnel, --tunnel-control)
  * Parse target string in format: user[@clientid[.wssshd-host[:sshstring]]]
  * Build ProxyCommand using wsssht --pipe with appropriate options
  * Find wsssht in PATH or same directory as wsssh
  * Construct and execute SSH command with ProxyCommand
  * Debug mode shows constructed command without executing
- Add wsssh to build system (configure.sh and Makefile)
- Update debian/control to include wsssh in package description
- Create comprehensive man page (man/wsssh.1) with usage examples
- Tested functionality with various command line options

wsssh provides a convenient wrapper around SSH that automatically sets up
WebSocket tunneling through wsssht, making it easy to use SSH with WebSocket
relays without manual ProxyCommand configuration.
parent 66a58d82
...@@ -58,12 +58,12 @@ LDFLAGS = $(shell pkg-config --libs openssl) ...@@ -58,12 +58,12 @@ LDFLAGS = $(shell pkg-config --libs openssl)
# Source files # Source files
LIB_SRCS = libwsssht/wssshlib.c libwsssht/websocket.c libwsssht/wssh_ssl.c libwsssht/tunnel.c libwsssht/utils.c libwsssht/modes.c libwsssht/threads.c LIB_SRCS = libwsssht/wssshlib.c libwsssht/websocket.c libwsssht/wssh_ssl.c libwsssht/tunnel.c libwsssht/utils.c libwsssht/modes.c libwsssht/threads.c
LIB_OBJS = $(LIB_SRCS:.c=.o) LIB_OBJS = $(LIB_SRCS:.c=.o)
SRCS = wssshc.c wsssht.c SRCS = wssshc.c wsssht.c wsssh.c
OBJS = $(SRCS:.c=.o) OBJS = $(SRCS:.c=.o)
TARGETS = wssshc wsssht TARGETS = wssshc wsssht wsssh
# Man pages # Man pages
MANPAGES = man/wssshc.1 man/wsssht.1 MANPAGES = man/wssshc.1 man/wsssht.1 man/wsssh.1
# Default target # Default target
all: $(TARGETS) all: $(TARGETS)
...@@ -75,6 +75,9 @@ wssshc: wssshc.o libwsssht/wssshlib.o libwsssht/websocket.o libwsssht/wssh_ssl.o ...@@ -75,6 +75,9 @@ wssshc: wssshc.o libwsssht/wssshlib.o libwsssht/websocket.o libwsssht/wssh_ssl.o
wsssht: wsssht.o $(LIB_OBJS) wsssht: wsssht.o $(LIB_OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
wsssh: wsssh.o
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
# Object files # Object files
%.o: %.c %.o: %.c
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
...@@ -103,12 +106,16 @@ uninstall: ...@@ -103,12 +106,16 @@ uninstall:
# Remove from both possible locations # Remove from both possible locations
rm -f $(DESTDIR)/usr/local/bin/wssshc rm -f $(DESTDIR)/usr/local/bin/wssshc
rm -f $(DESTDIR)/usr/local/bin/wsssht rm -f $(DESTDIR)/usr/local/bin/wsssht
rm -f $(DESTDIR)/usr/local/bin/wsssh
rm -f $(DESTDIR)/usr/local/share/man/man1/wssshc.1 rm -f $(DESTDIR)/usr/local/share/man/man1/wssshc.1
rm -f $(DESTDIR)/usr/local/share/man/man1/wsssht.1 rm -f $(DESTDIR)/usr/local/share/man/man1/wsssht.1
rm -f $(DESTDIR)/usr/local/share/man/man1/wsssh.1
rm -f $(DESTDIR)/usr/bin/wssshc rm -f $(DESTDIR)/usr/bin/wssshc
rm -f $(DESTDIR)/usr/bin/wsssht rm -f $(DESTDIR)/usr/bin/wsssht
rm -f $(DESTDIR)/usr/bin/wsssh
rm -f $(DESTDIR)/usr/share/man/man1/wssshc.1 rm -f $(DESTDIR)/usr/share/man/man1/wssshc.1
rm -f $(DESTDIR)/usr/share/man/man1/wsssht.1 rm -f $(DESTDIR)/usr/share/man/man1/wsssht.1
rm -f $(DESTDIR)/usr/share/man/man1/wsssh.1
.PHONY: all clean install uninstall .PHONY: all clean install uninstall
EOF EOF
......
...@@ -16,4 +16,5 @@ Description: WebSocket SSH Tools - C implementation ...@@ -16,4 +16,5 @@ Description: WebSocket SSH Tools - C implementation
route SSH/SCP traffic through registered client machines. route SSH/SCP traffic through registered client machines.
. .
This package contains the C implementation of the WebSocket SSH tools: This package contains the C implementation of the WebSocket SSH tools:
wssshc (client registration) and wsssht (tunnel setup tool with pipe mode). wssshc (client registration), wsssht (tunnel setup tool with pipe mode),
\ No newline at end of file and wsssh (SSH wrapper with ProxyCommand support).
\ No newline at end of file
.TH WSSH 1 "September 2024" "wsssh 1.0" "WebSocket SSH Tools"
.SH NAME
wsssh \- SSH wrapper with WebSocket ProxyCommand support
.SH SYNOPSIS
.B wsssh
[\fB\-\-help\fR] [\fB\-\-clientid\fR \fIclient_id\fR] [\fB\-\-wssshd\-host\fR \fIhost\fR]
[\fB\-\-wssshd\-port\fR \fIport\fR] [\fB\-\-debug\fR] [\fB\-\-tunnel\fR \fItransport\fR]
[\fB\-\-tunnel\-control\fR \fItransport\fR] [\fIuser\fR][\fB@\fR[\fIclientid\fR][\fB.\fR[\fIwssshd\-host\fR]][\fB:\fR[\fIsshstring\fR]]]
[\fIssh_options\fR...]
.SH DESCRIPTION
.B wsssh
is an SSH wrapper that automatically configures SSH to use WebSocket tunnels through
.B wsssht
with ProxyCommand. It parses the target specification and constructs the appropriate
SSH command with ProxyCommand to establish secure connections through WebSocket relays.
.SH OPTIONS
.TP
.B \-\-help
Show help message and exit.
.TP
.B \-\-clientid \fIclient_id\fR
Specify the client ID of the registered wssshc endpoint.
.TP
.B \-\-wssshd\-host \fIhost\fR
Specify the wssshd relay host.
.TP
.B \-\-wssshd\-port \fIport\fR
Specify the wssshd relay websocket port (default: 9898).
.TP
.B \-\-debug
Enable debug output. When debug is enabled, the SSH command is displayed but not executed.
.TP
.B \-\-tunnel \fItransport\fR
Select data channel transport (comma-separated or 'any').
.TP
.B \-\-tunnel\-control \fItransport\fR
Select control channel transport (comma-separated or 'any').
.SH TARGET FORMAT
The target specification follows the format:
.sp
\fIuser\fR[\fB@\fR[\fIclientid\fR][\fB.\fR[\fIwssshd\-host\fR]][\fB:\fR[\fIsshstring\fR]]]
.sp
Where:
.RS
.TP
\fIuser\fR
SSH username
.TP
\fIclientid\fR
Client ID of the registered wssshc endpoint
.TP
\fIwssshd\-host\fR
wssshd relay hostname
.TP
\fIsshstring\fR
Additional SSH connection string (e.g., port number)
.RE
.SH EXAMPLES
.TP
Connect to myclient:
.B wsssh user@myclient
.TP
Connect with specific relay host:
.B wsssh user@myclient.server.com
.TP
Connect with custom port:
.B wsssh user@myclient.server.com:2222
.TP
Enable debug output:
.B wsssh \-\-debug user@myclient.server.com
.TP
Specify transport:
.B wsssh \-\-tunnel websocket user@myclient.server.com
.TP
Pass additional SSH options:
.B wsssh user@myclient.server.com -p 2222 -o StrictHostKeyChecking=no
.SH ENVIRONMENT
.B wsssh
requires
.B wsssht
to be available either in PATH or in the same directory as wsssh.
.SH SEE ALSO
.BR wsssht (1),
.BR wssshc (1),
.BR ssh (1)
.SH AUTHOR
Written by Stefy Lanza <stefy@nexlab.net> and SexHack.me
.SH COPYRIGHT
Copyright \(co 2024 Stefy Lanza <stefy@nexlab.net> and SexHack.me
.br
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
.SH BUGS
Report bugs to <stefy@nexlab.net>
\ No newline at end of file
This diff is collapsed.
/*
* WebSocket SSH (wsssh) - SSH Wrapper with WebSocket ProxyCommand
*
* Copyright (C) 2024 Stefy Lanza <stefy@nexlab.net> and SexHack.me
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef WSSH_H
#define WSSH_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
// Configuration structure for wsssh
typedef struct {
char *client_id;
char *wssshd_host;
int wssshd_port;
int debug;
char *tunnel;
char *tunnel_control;
char *user;
char *target_host;
char *ssh_string;
int remaining_argc;
char **remaining_argv;
} wsssh_config_t;
// Function declarations
void print_wsssh_usage(const char *program_name);
int parse_wsssh_args(int argc, char *argv[], wsssh_config_t *config);
int parse_target_string(const char *target, wsssh_config_t *config);
char *build_proxy_command(wsssh_config_t *config);
char *build_ssh_command(wsssh_config_t *config, const char *proxy_command);
int execute_ssh_command(const char *ssh_command, int debug);
#endif // WSSH_H
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment