Created
September 24, 2018 12:43
-
-
Save BrunIF/85bace9a37906229b1438a86b1923ae0 to your computer and use it in GitHub Desktop.
Make own tunneling over SSH based on Serveo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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