Configuring Tor v3 Hidden Services and SSH Connections
Introduction
In this article, we will discuss how to set up a Tor v3 hidden service and use it for SSH connections. This setup enhances your network’s privacy and security, allowing secure, anonymous access to your services.

Server Configuration
Setting Up a Single Hidden Address Service
-
Install Tor:
sudo apt-get install tor- Verify the process:
sudo lsof -i | grep LISTEN - Terminate if necessary:
sudo kill <pid>
- Verify the process:
-
Configure the Tor Service: Edit
/etc/tor/torrc:HiddenServiceDir /home/<username>/<hiddenfile_A> HiddenServicePort 22 127.0.0.1:22-
HiddenServiceDir: Set to/home/<username>/<hiddenfile_A>. Modify permissions withsudo chmod 700 /home/<username>/<hiddenfile_A>. -
HiddenServicePort: Map a hidden service port to a local port (22 in this case for SSH).
-
-
Start Tor:
- Run
tor. - This generates private and public keys and a hostname in
/home/<username>/<hiddenfile_A>.
- Run
Configuring Multiple Hidden Address Services
-
Modify Tor Configuration: Edit
/etc/tor/torrcto add multiple services:HiddenServiceDir /home/<username>/<hiddenfile_X> HiddenServicePort 80 127.0.0.1:<localport>- Replace
<hiddenfile_X>and<localport>as needed. - Each
HiddenServiceDircreates a unique hidden address.
- Replace
-
Start Tor:
- Run
tor. - Check created folders for generated keys and addresses.
- Run
SSH Client Configuration
-
Install Tor on the Client:
brew install tor tor -
Modify SSH Configuration: Edit
.ssh/configand add:Host *.onion *-tor ProxyCommand nc -X 5 -x 127.0.0.1:9050 %h %p CheckHostIP no Compression yes Protocol 2 -
Connect via SSH:
ssh <username>@<hostname-onion>.onion
Reference: SSH Hidden Service Guide
Generating Custom Tor v3 Addresses
-
Download and Install Tools:
sudo apt-get install git
git clone https://github.com/cathugger/mkp224o.git
cd mkp224o
sudo apt install gcc libsodium-dev make autoconf
-
Compile the Software:
./autogen.sh ./configure ./configure CPPFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" make -
Use the Tool:
- Caution: Avoid setting very short terms (≤3 characters) to prevent rapid generation, which can damage the disk or create files that are hard to delete.
./mkp224o <term_A> <term_B> <...> - Use
-S 1for status updates every second (default is every 10 seconds). - Use
-j 10to set the number of CPU cores (default uses all available).
- Caution: Avoid setting very short terms (≤3 characters) to prevent rapid generation, which can damage the disk or create files that are hard to delete.
Generated results will appear in folders named <onionaddress>.onion, containing private keys, public keys, and the address. To activate, move these to the /home/<username>/<hiddenfile_*> directory.
Reference: mkp224o GitHub Repository
Enjoy Reading This Article?
Here are some more articles you might like to read next: