SSH (Secure Shell) and SSL/TLS (Transport Layer Security) are distinct security protocols. While SSH has its own encryption mechanisms, wrapping it inside SSL/TLS creates an additional layer that can help bypass network restrictions that may block standard SSH connections but allow HTTPS traffic (which uses port 443 and TLS).
Tunneling SSH through SSL/TLS offers several advantages:
To enable SSH over SSL/TLS, you need to configure both the server and client sides. Let's start with setting up the server.
# On Ubuntu/Debian
sudo apt update
sudo apt install stunnel4
# On CentOS/RHEL
sudo yum install stunnel
Create or edit the stunnel configuration file:
sudo nano /etc/stunnel/stunnel.conf
Add the following configuration:
[ssh]
accept = 443
connect = 22
cert = /etc/stunnel/stunnel.pem
key = /etc/stunnel/stunnel.pem
sudo openssl req -new -x509 -days 365 -nodes -out /etc/stunnel/stunnel.pem -keyout /etc/stunnel/stunnel.pem
sudo chmod 600 /etc/stunnel/stunnel.pem
sudo systemctl enable stunnel4
sudo systemctl start stunnel4
You can also use Nginx as a reverse proxy to forward HTTPS traffic to SSH:
sudo apt update
sudo apt install nginx
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/cert.key -out /etc/nginx/cert.crt
Configure Nginx:
server {
listen 443 ssl;
ssl_certificate /etc/nginx/cert.crt;
ssl_certificate_key /etc/nginx/cert.key;
location / {
proxy_pass http://localhost:22;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
HTTP Custom is an Android application that allows you to use SSH tunnels with SSL/TLS. Here's how to set it up:
Download HTTP Custom from the Google Play Store or from trusted APK sources.
Setting | Value | Description |
---|---|---|
Connection Type | SSH Direct | Choose SSH Direct for direct connections |
SSH Host | Your server IP | The IP address of your SSH server |
Port | 443 | The port where stunnel is listening |
SSH Username | Your SSH username | The username for your SSH account |
SSH Password | Your SSH password | The password for your SSH account |
SSH Method | SSL/TLS | Enable SSL/TLS tunneling |
SNI Host | Optional domain | If using SNI, enter host domain |
Setting | Value | Purpose |
---|---|---|
Custom Payload | Optional | Custom HTTP header for specific networks |
Payload Position | Front/Back | Where to insert the custom payload |
Connection Method | Direct/Proxy | How to connect to the SSH server |
Force HTTPS | Enabled | Force all connections over HTTPS |
After configuration:
If setting up your own server is challenging, several services offer free SSH SSL/TLS accounts:
Most free SSH SSL/TLS services follow a similar account creation process:
Before using SSH SSL/TLS tunneling, be aware of these important points:
Best Practice | Recommendation |
---|---|
Use strong passwords | Create complex, unique passwords for your SSH accounts |
Regular updates | Keep your SSH clients and servers updated |
Trusted services | Use reputable SSH service providers |
Connection monitoring | Regularly check active connections to your SSH server |
Key-based authentication | Use SSH keys instead of passwords when possible |