Skip to content

Instantly share code, notes, and snippets.

View VSharapov's full-sized avatar
☁️
Tiny webapps on free tier - https://news.ycombinator.com/item?id=26242844

Vasiliy Sharapov VSharapov

☁️
Tiny webapps on free tier - https://news.ycombinator.com/item?id=26242844
  • rotor.ai
  • Boston, MA
  • 14:21 (UTC -05:00)
View GitHub Profile
@VSharapov
VSharapov / Persistent reverse SSH tunnel.md
Created September 30, 2024 04:56 — forked from Duckle29/Persistent reverse SSH tunnel.md
A systemd service file to ensure a persistent reverse SSH tunnel is active

Persistent reverse-ssh-tunnel systemd unit

This unit file, if enabled on boot, will attempt to connect to a remote server and establish a reverse tunnel. It uses StrictHostKeyChecking=accept-new for the ssh connection, so if you want to make sure the host you're connecting to is the right one, carry out the first connection manually and check the key.

REMOTE is considered a remote server that's available over ssh
LOCAL is considered the device initiating the remote tunnel. This will likely be a device dropped behind a NAT with no option of portforwarding

To use it, copy this multiline command somewhere to edit the configs and run it as root on the device:

#!/bin/bash
trap 'echo "# $BASH_COMMAND";read' DEBUG
# You'll get a preview of the following line and have to hit return here
echo codeLine1
# You'll get a preview of the following line and have to hit return here
echo codeLine2
# You'll get a preview of the following line and have to hit return here
trap - DEBUG
@VSharapov
VSharapov / SimpleHTTPServerWithUpload.py
Created June 9, 2022 13:56 — forked from touilleMan/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload - Python3 version
#!/usr/bin/env python3
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
see: https://gist.github.com/UniIsland/3346170
"""
@VSharapov
VSharapov / randword.sh
Last active January 14, 2020 15:19 — forked from stevebest/randword.sh
Pick a random word from a dictionary
#! /usr/bin/env bash
WORDFILE="/usr/share/dict/words"
words=$(cat $WORDFILE | wc -l)
r=$(((RANDOM * 32768 + RANDOM)%$words+1))
sed -n "$r p" $WORDFILE
@VSharapov
VSharapov / ask.sh
Last active May 27, 2020 05:12 — forked from tlamer/README.md
function ask {
while true; do
if [ "${2:-}" = "Y" ]; then
prompt="Y/n"
default=Y
elif [ "${2:-}" = "N" ]; then
prompt="y/N"
default=N
else