How to set up an encrypted tunnel between a server in Russia and a panel server in Germany?
I need to establish a secure connection between a VDS in Russia and a panel server in Germany using encryption. The main difficulty is that I don’t have rights to install additional software on the German server - only the IP address and port are available.
The solution should:
- Have the Russian server send encrypted traffic to Germany (to bypass possible Roskomnadzor/RKN blocking)
- Have the German server accept this traffic and forward it to the panel hosting without encryption
Is it possible to implement such an architecture? What technologies and protocols can be used to create such a tunnel?
Creating an Encrypted Tunnel Between a Russian Server and a German Panel Server Without Root Access on the German Server
To create an encrypted tunnel between a server in Russia and a panel server in Germany without root access on the German server, you can use SSH tunneling, including reverse SSH tunnels and SOCKS proxies. This technology allows you to establish a secure encrypted connection that will redirect traffic from the Russian server through the German server to your panel hosting, bypassing possible Roskomnadzor (RKN) blocks.
Table of Contents
- Basic SSH Tunnel Approaches
- Reverse SSH Tunnel Setup
- Using SOCKS Proxy through SSH
- Maintaining Persistent Connection
- Security and Optimization
- Alternative Solutions
Basic SSH Tunnel Approaches
Several SSH tunneling technologies are suitable for your task:
Reverse SSH Tunnel
A reverse SSH tunnel allows your Russian server to establish an outgoing connection to the German server, after which the German server can “access” the Russian server through this tunnel. This is the ideal solution when you don’t have root access on the German server.
Advantages of this approach:
- Doesn’t require root access on the German server
- Bypasses firewall restrictions on the German side
- Provides a fully encrypted data transmission channel
Dynamic Tunneling (SOCKS Proxy)
A SOCKS proxy through SSH creates dynamic tunneling, allowing you to redirect any network traffic through an encrypted SSH channel.
Reverse SSH Tunnel Setup
To set up a reverse SSH tunnel, follow these steps:
On the Russian server (connection initiator)
# Basic command for creating a reverse tunnel
ssh -N -R 2222:localhost:80 user@german-server-ip
Where:
2222- port on the German server that SSH will listen onlocalhost:80- local port and host on the Russian serveruser@german-server-ip- connection details for the German server
Configuration for redirecting traffic to panel hosting
If you need to redirect traffic to panel hosting, use:
# For redirecting traffic to panel hosting
ssh -N -R 8080:panel-hosting-ip:80 user@german-server-ip
Automatic connection with keys
For automated connection, use SSH keys:
# Generate SSH key on Russian server
ssh-keygen -t rsa -b 4096
# Copy key to German server
ssh-copy-id -i ~/.ssh/id_rsa.pub user@german-server-ip
Using SOCKS Proxy through SSH
A SOCKS proxy through SSH allows you to redirect all network traffic through an encrypted channel:
Setting up SOCKS Proxy
On the Russian server, execute:
# Creating SOCKS proxy through SSH
ssh -D 1080 user@german-server-ip
Configuring applications to use SOCKS proxy
For browsers and other applications, configure them to use SOCKS proxy at localhost:1080.
Example browser configuration
- Open browser settings
- Go to proxy settings
- Select SOCKS proxy
- Specify address:
localhost - Port:
1080
Maintaining Persistent Connection
To maintain SSH connection constantly, use autossh:
Installing autossh (if access is available)
# On Russian server
sudo apt-get install autossh # For Debian/Ubuntu
sudo yum install autossh # For CentOS/RHEL
Configuring autossh for persistent tunnel
# Start autossh with automatic recovery
autossh -M 0 -N -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" \
-R 8080:localhost:80 user@german-server-ip
Starting via systemd (if access is available)
If you have limited root access, you can create a service:
# Create service file
sudo nano /etc/systemd/system/ssh-tunnel.service
File contents:
[Unit]
Description=SSH Tunnel Service
After=network.target
[Service]
User=your-user
ExecStart=/usr/bin/autossh -M 0 -N -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -R 8080:localhost:80 user@german-server-ip
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
Security and Optimization
Configuring SSH for security
Optimize the /etc/ssh/sshd_config file on the Russian server:
# Allow only key authentication
PasswordAuthentication no
PubkeyAuthentication yes
# Limit SSH access
AllowUsers your-user
Using dynamic ports
For enhanced security, use dynamic ports:
# Using different ports for different sessions
ssh -N -R 8080:localhost:80 user@german-server-ip
ssh -N -R 8081:localhost:443 user@german-server-ip
Encryption and compression
Add parameters to improve performance:
# Enable compression and select cipher algorithms
ssh -C -c aes256-gcm@openssh.com -o Compression=yes user@german-server-ip
Alternative Solutions
Using existing services
If setting up your own tunnel is complex, consider using:
- Pinggy - a service that creates SSL tunnels
- ngrok - creating tunnels with web interface
- localtunnel - simple tunnels for development
Bypassing firewall restrictions
If the German server blocks incoming connections:
# Using an intermediate server
ssh -N -R 8080:localhost:80 intermediate-user@intermediate-server
ssh -N -L 8080:localhost:8080 user@german-server-ip
Monitoring and logging
For debugging, use verbose mode:
# Detailed SSH connection logging
ssh -vvv -N -R 8080:localhost:80 user@german-server-ip
Sources
- Reverse SSH Tunneling: The Ultimate Guide - qbee.io
- How does reverse SSH tunneling work? - Unix & Linux Stack Exchange
- Reverse SSH Tunneling - HowtoForge
- Comprehensive Guide to Reverse SSH Tunneling in Linux - JFrog
- Creating a persistent reverse SSH connection from remote server to home client - Ask Ubuntu
- Remote access using reverse ssh tunnel, without port forwarding - Raspberry Pi Stack Exchange
- SSH Reverse Tunneling - Pinggy
- with SSH only: reverse tunnel web access via ssh SOCKS proxy - Server Fault
- Persistent Reverse SSH Tunnel - Keeper Documentation
- SSH Tunneling and Proxying - Baeldung on Linux
Conclusion
For creating an encrypted tunnel between a server in Russia and a panel server in Germany without root access on the German side, the optimal solution is to use a reverse SSH tunnel. This technology allows you to:
- Bypass firewall restrictions - the Russian server establishes an outgoing connection that is used for reverse access
- Ensure full security - all traffic is encrypted using SSH
- Not require root access - standard SSH access to the German server is sufficient
- Automate connection - with
autossh, the connection will be restored when interrupted
The recommended implementation includes creating a reverse SSH tunnel using authentication keys and maintaining automatic connection. To redirect traffic to panel hosting, configure the appropriate ports in the tunnel.
As an alternative, you can consider using a SOCKS proxy through SSH, which provides more flexible options for redirecting different types of traffic.