2020-07-04 03:24:03 +02:00
|
|
|
*Shamelessly copied from https://www.techrepublic.com/article/how-to-run-an-ssh-connection-through-tor/*
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
# Install Tor
|
|
|
|
|
|
|
|
Install Tor on both client and server:
|
|
|
|
|
|
|
|
sudo apt-get install tor -y
|
|
|
|
|
|
|
|
# Configure Tor
|
|
|
|
|
2020-07-08 04:37:19 +02:00
|
|
|
1. In the server let's edit tor's config file `/etc/tor/torrc`:
|
2020-07-04 03:24:03 +02:00
|
|
|
|
2020-07-08 04:37:19 +02:00
|
|
|
sudo nano /etc/tor/torrc
|
2020-07-04 03:24:03 +02:00
|
|
|
|
2020-07-08 04:37:19 +02:00
|
|
|
2. At the bottom of that file, add this:
|
2020-07-04 03:24:03 +02:00
|
|
|
|
2020-07-08 04:37:19 +02:00
|
|
|
HiddenServiceDir /var/lib/tor/ssh/
|
|
|
|
HiddenServicePort 22
|
2020-07-04 03:24:03 +02:00
|
|
|
|
2020-07-08 04:37:19 +02:00
|
|
|
<kbd>Ctrl</kbd>+<kbd>x</kbd> to save and close file.
|
2020-07-04 03:24:03 +02:00
|
|
|
|
2020-07-08 04:37:19 +02:00
|
|
|
3. Restart Tor:
|
2020-07-04 03:24:03 +02:00
|
|
|
|
2020-07-08 04:37:19 +02:00
|
|
|
sudo systemctl restart tor
|
2020-07-04 03:24:03 +02:00
|
|
|
|
2020-07-08 04:37:19 +02:00
|
|
|
# Get .onion address
|
2020-07-04 03:24:03 +02:00
|
|
|
|
2020-07-08 04:37:19 +02:00
|
|
|
It will be in the file `hostname` in the previously configured folder `/var/lib/tor/ssh`
|
2020-07-04 03:24:03 +02:00
|
|
|
|
|
|
|
sudo cat /var/lib/tor/ssh/hostname
|
|
|
|
|
|
|
|
You should get something like `riludi2kstjwmlzn.onion`
|
|
|
|
|
|
|
|
# Connect to the Tor hidden ssh server
|
|
|
|
|
2020-07-08 04:37:19 +02:00
|
|
|
```bash
|
|
|
|
torify ssh ... # replace the domain/ip with the .onion address
|
|
|
|
```
|
2020-07-04 03:24:03 +02:00
|
|
|
|
|
|
|
For example:
|
|
|
|
|
|
|
|
torify ssh jack@riludi2kstjwmlzn.onion
|
|
|
|
|
2020-07-08 04:37:19 +02:00
|
|
|
## Optional
|
|
|
|
|
|
|
|
You don't need to remember the **.onion** address, you can write an entry to your user's ssh config file `~/.ssh/config`:
|
|
|
|
|
|
|
|
nano ~/.ssh/config
|
|
|
|
|
|
|
|
Set configuration:
|
|
|
|
|
|
|
|
Host serverTor
|
|
|
|
User jack
|
|
|
|
HostName riludi2kstjwmlzn.onion
|
|
|
|
Port 22
|
2020-07-04 03:24:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
Now you can simply connect with:
|
|
|
|
|
|
|
|
torify ssh serverTor
|