Skip to content

Instantly share code, notes, and snippets.

@lukechilds
Last active September 21, 2021 16:06

Revisions

  1. lukechilds revised this gist Sep 21, 2021. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions tor-ssh.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    #!/usr/bin/env bash
    #
    # Setup or remove an SSH hidden service on Debian based systems.
    #
    # Usage:
    #
    # Setup SSH hidden service:
  2. lukechilds revised this gist Sep 21, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions tor-ssh.sh
    Original file line number Diff line number Diff line change
    @@ -7,6 +7,7 @@
    #
    # Remove SSH hidden service:
    # $ curl -Ls https://git.io/tor-ssh | bash -s -- --remove-tor-ssh

    setup_ssh_hidden_service() {
    echo "Installing Tor..."
    echo ""
  3. lukechilds revised this gist Sep 21, 2021. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion tor-ssh.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,12 @@
    #!/usr/bin/env bash

    #
    # 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 ""
  4. lukechilds revised this gist Sep 21, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions tor-ssh.sh
    Original file line number Diff line number Diff line change
    @@ -35,6 +35,7 @@ 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"
  5. lukechilds created this gist Sep 21, 2021.
    41 changes: 41 additions & 0 deletions tor-ssh.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    #!/usr/bin/env bash

    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" ]]
    remove_ssh_hidden_service
    else
    echo "Invalid argument, pass in --setup-tor-ssh or --remove-tor-ssh"
    fi