Last active
September 21, 2021 16:06
-
-
Save lukechilds/0975c950e64cc6ec3c99354ddce33ee0 to your computer and use it in GitHub Desktop.
Setup or remove an SSH hidden service on Debian based systems
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
#!/usr/bin/env bash | |
# | |
# Setup or remove an SSH hidden service on Debian based systems. | |
# | |
# Usage: | |
# | |
# Setup SSH hidden service: | |
# $ curl -Ls https://git.io/tor-ssh | bash -s -- --setup-tor-ssh | |
# | |
# Remove SSH hidden service: | |
# $ curl -Ls https://git.io/tor-ssh | bash -s -- --remove-tor-ssh | |
setup_ssh_hidden_service() { | |
echo "Installing Tor..." | |
echo "" | |
sudo apt-get install -y tor | |
echo "Adding SSH hidden service to torrc..." | |
echo "" | |
torrc_data=" | |
SocksPort 0 | |
HiddenServiceDir /var/lib/tor/umbrel-remote-ssh/ | |
HiddenServicePort 22 127.0.0.1:22" | |
echo "${torrc_data}" | sudo tee --append /etc/tor/torrc | |
echo "Restarting Tor to load changes..." | |
echo "" | |
sudo systemctl restart tor | |
sleep 5 | |
echo "Getting Tor hidden service address..." | |
echo "" | |
sudo cat /var/lib/tor/umbrel-remote-ssh/hostname | |
} | |
remove_ssh_hidden_service() { | |
echo "Removing Tor..." | |
echo "" | |
sudo apt-get purge -y tor | |
} | |
arg="${1}" | |
if [[ "${arg}" == "--setup-tor-ssh" ]] | |
then | |
setup_ssh_hidden_service | |
elif [[ "${arg}" == "--remove-tor-ssh" ]] | |
then | |
remove_ssh_hidden_service | |
else | |
echo "Invalid argument, pass in --setup-tor-ssh or --remove-tor-ssh" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment