Skip to content

Instantly share code, notes, and snippets.

@jcroot
Forked from BrunIF/serveo.sh
Created November 12, 2019 16:53
Show Gist options
  • Save jcroot/4997ac679f7c19b76e0c3f9a19879628 to your computer and use it in GitHub Desktop.
Save jcroot/4997ac679f7c19b76e0c3f9a19879628 to your computer and use it in GitHub Desktop.
Make own tunneling over SSH based on Serveo
#!/bin/bash
# Change `site.com` - to own name
read SERVER_NAME
sudo -s
# Change codepage
export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
# Update and install software
apt update
apt install git python-minimal
ssh-keygen
# Get serveo
mkdir /opt/serveo
cd /opt/serveo
wget https://storage.googleapis.com/serveo/download/2018-05-08/serveo-linux-amd64
mv ./serveo-linux-amd64 ./serveo
chmod +x ./serveo
ln -s /opt/serveo/serveo /usr/local/bin/
# Install Certbot-auto with dependencies
cd /opt
git clone https://github.com/certbot/certbot.git
cd certbot && ln -s /opt/certbot/certbot-auto /opt/certbot/certbot && ./certbot
ln -s /opt/certbot/certbot-auto /usr/local/bin/certbot
apt install letsencrypt
# Get certificates for all sub-domains
certbot certonly --manual --preferred-challenges dns -d *.${SERVER_NAME}
# Rename certificates name to serveo use
cp /etc/letsencrypt/live/${SERVER_NAME}/cert.pem /etc/letsencrypt/live/${SERVER_NAME}/ssh.crt
cp /etc/letsencrypt/live/${SERVER_NAME}/privkey.pem /etc/letsencrypt/live/${SERVER_NAME}/ssh.key
serveo -private_key_path=$HOME/.ssh/id_rsa -cert_dir=/etc/letsencrypt/live/${SERVER_NAME}/ -domain=${SERVER_NAME} -port=22 -http_port=80 -https_port=443 -allow_ssh_on_https_port
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment