Skip to content

Instantly share code, notes, and snippets.

@shafiqsaaidin
Created September 3, 2020 03:58
Show Gist options
  • Save shafiqsaaidin/7348d23efa5d6394f7b4ff7bb8b8ff9f to your computer and use it in GitHub Desktop.
Save shafiqsaaidin/7348d23efa5d6394f7b4ff7bb8b8ff9f to your computer and use it in GitHub Desktop.
SSH over Stunnel basic setup for debian
Title : SSH over Stunnel basic setup for debian
Date : 03/09/2020
Author : musha
Reference : https://medium.com/@jayden.chua/stunnel-openvpn-server-on-ubuntu-18-04-1837eaf2077d
: https://hamy.io/post/0012/how-to-install-and-configure-stunnel-on-ubuntu/#gsc.tab=0
$ apt install stunnel4
$ cd /etc/stunnel
$ openssl genrsa -out key.pem 2048
$ openssl req -new -x509 -key key.pem -out cert.pem -days 3650
$ cat key.pem cert.pem >> stunnel.pem
$ openssl pkcs12 -export -out stunnel.p12 -inkey key.pem -in cert.pem
## Configure stunnel server
$ echo -e '\xef\xbb\xbf; BOM composed of non printable characters. It is here, before the semicolon!' > /etc/stunnel/stunnel.conf
$ nano /etc/stunnel/stunnel.conf
pid = /var/run/stunnel4/stunnel.pid
output = /var/log/stunnel4/stunnel.log
setuid = stunnel4
setgid = stunnel4
# https://www.stunnel.org/faq.html
socket = r:TCP_NODELAY=1
socket = l:TCP_NODELAY=1
debug = 4
[ssh_tls-server]
accept = 443
connect = 127.0.0.1:44200
cert = /etc/stunnel/stunnel.pem
$ systemctl start stunnel4
$ systemctl enable stunnel4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment