Last active
December 28, 2022 20:30
-
-
Save ABalanuta/69de0bfd041af0c7c9376c9696c0d6fc to your computer and use it in GitHub Desktop.
TOR_BootStrap_tor_over_ssh
This file contains 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 | |
# From: https://gitlab.com/grownetics/devops/blob/master/tor_ssh.sh | |
# TOR Setup Script | |
# Author: Nick Busey | |
# | |
# This file is meant to get SSH access via Tor to a server in one command. | |
# | |
# Usage (as root): $ bash <(curl -s https://gitlab.com/grownetics/devops/raw/master/tor_ssh.sh) | |
# | |
# Client Config Example | |
# | |
# In order to connect to the hostnames output by this file, you should have the TOR browser running | |
# and your ~/.ssh/config should contain the following 2 lines: | |
# | |
# Host *.onion | |
# ProxyCommand /usr/bin/nc -xlocalhost:9150 -X5 %h %p | |
# | |
# Now once you get a hostname back from the script (e.g.: tmxybgr6e7kpenoq.onion) | |
# you can connect to it like a normal host. | |
# | |
# Example: `ssh vagrant@tmxybsgr6e7kpenoq.onion` | |
# Install Tor | |
apt-get update && apt-get install -y tor | |
# Append the hidden service configuration to the Torrc file | |
echo -e "HiddenServiceDir /var/lib/tor/onion-ssh/\nHiddenServicePort 9022 127.0.0.1:22" > /etc/tor/torrc | |
# Remove the bogus tor service Ubuntu installs by default | |
#rm /lib/systemd/system/tor.service | |
# Ensure the changes are recognized | |
#systemctl daemon-reload | |
# Restart Tor to generate the new configuration | |
#/etc/init.d/tor restart | |
sudo systemctl status tor | |
sudo systemctl restart tor | |
# Wait 30 seconds for the configuration to generate | |
echo "Wait 30 seconds for Tor to start and generate the hostname" && sleep 30 | |
# Output the Hostname file contents. | |
echo "You can now SSH to: " && sudo cat /var/lib/tor/onion-ssh/hostname |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment