Wetty is a web-based terminal. It runs a small Node.js server that opens an SSH session and streams it to your browser over WebSockets, so you can reach an EC2 instance from any browser without an SSH client. The steps above run Wetty in Docker on Ubuntu. Below them you will find the settings needed to make it reach the EC2 host itself, how to log in when Ubuntu AMIs block password authentication, and how to lock the setup down before you expose it to the internet.
โ 1. Install Docker (if not installed)
sudo apt update
sudo apt install -y docker.io
sudo systemctl enable --now docker
Code language: CSS (css)
โ 2. Start Wetty using Docker (recommended + stable)
This avoids all Node/gc-stats errors you faced earlier.
Run Wetty in container:
sudo docker run -d \
--name wetty \
-p 80:3000 \
wettyoss/wetty \
--ssh-host=127.0.0.1
What this means:
- Docker runs Wetty internally on port 3000
- EC2 instance listens on port 80
- No need for Node.js / npm on host
- No gc-stats errors
- Very stable
Run Wetty in container BUT access the HOST Machine
sudo docker run -d \
--name wetty \
-p 80:3000 \
wettyoss/wetty \
--force-ssh \
--ssh-host=172.31.47.185 \
--ssh-port=22 \
--ssh-user=ubuntu
โ 3. Access Wetty in your browser
Use either:
http://13.200.229.28/wetty
Code language: JavaScript (javascript)
or
http://ec2-13-200-229-28.ap-south-1.compute.amazonaws.com/wetty
Code language: JavaScript (javascript)
โ ๏ธ Wetty does NOT load on / โ You must add /wetty
โ 4. Verify Container is Running
docker ps
Should show:
PORTS
0.0.0.0:80->3000/tcp
How Wetty works and what you need first
Wetty does not replace SSH. The container runs a web server on port 3000 under the base path /wetty. When a browser connects, Wetty starts an ssh client inside the container and connects to whatever --ssh-host points at. If --ssh-host is the EC2 instance, the instance needs a running sshd and a way for the user to authenticate.
- An EC2 instance running Ubuntu (the commands above use
apt). On Amazon Linux, install Docker withsudo dnf install -y dockerand thensudo systemctl enable --now docker. - A security group inbound rule for TCP 80 (or 443 if you add TLS). Restrict the source to your own IP (
x.x.x.x/32), not0.0.0.0/0. - A way to authenticate over SSH: a user with a password and password authentication enabled, or a key. See the login section below.
- Port 80 free on the host. Apache or Nginx already bound to port 80 will make the
docker runfail.
Corrected Docker command for reaching the EC2 host
The first command above uses --ssh-host=127.0.0.1. Inside a container, 127.0.0.1 is the container itself, not the EC2 instance. Also, when the host is localhost and --force-ssh is not set, Wetty runs a local login instead of SSH, so you end up with a prompt inside the container or a failed login. The second command fixes this by pointing at the instance's private IP, but the IP is hard-coded, and the command fails if the first container named wetty still exists. This version looks up the private IP from the instance metadata service (IMDSv2) and replaces any old container:
# Remove any earlier Wetty container (avoids "name already in use")
sudo docker rm -f wetty 2>/dev/null
# Get this instance's private IPv4 via IMDSv2
TOKEN=$(curl -s -X PUT "http://169.254.169.254/latest/api/token" \
-H "X-aws-ec2-metadata-token-ttl-seconds: 300")
PRIVATE_IP=$(curl -s -H "X-aws-ec2-metadata-token: $TOKEN" \
http://169.254.169.254/latest/meta-data/local-ipv4)
echo "$PRIVATE_IP"
# Run Wetty and SSH into the EC2 host
sudo docker run -d \
--name wetty \
--restart unless-stopped \
-p 80:3000 \
wettyoss/wetty \
--force-ssh \
--ssh-host="$PRIVATE_IP" \
--ssh-port=22 \
--ssh-user=ubuntuCode language: PHP (php)
--restart unless-stoppedbrings Wetty back after a reboot or a Docker restart. The original command has no restart policy.--force-sshmakes Wetty always use SSH, even if the target resolves to localhost.--ssh-user=ubuntuskips the username prompt. Leave it out if several users share the page.- The private IP stays the same across stop and start, unlike the public IP, so it is a safer target than the public address.
Another option is to skip the IP lookup and use Docker's host gateway alias. Add --add-host=host.docker.internal:host-gateway before the image name and set --ssh-host=host.docker.internal. Traffic then goes over the Docker bridge, so it never touches the security group.
Make SSH login work on Ubuntu AMIs
By default Wetty authenticates with a password. Ubuntu EC2 images allow key-only login and have no password for the ubuntu user, so the browser terminal shows Permission denied (publickey). To allow password login for this lab, run these commands on the instance (over your normal SSH session):
# Set a strong password for the ubuntu user
sudo passwd ubuntu
# Find where PasswordAuthentication is set (cloud images use a drop-in file)
sudo grep -ri passwordauthentication /etc/ssh/sshd_config /etc/ssh/sshd_config.d/
# Change "no" to "yes" in the file reported above, for example:
sudo sed -i 's/^PasswordAuthentication no/PasswordAuthentication yes/' \
/etc/ssh/sshd_config.d/60-cloudimg-settings.conf
# Validate and reload
sudo sshd -t && sudo systemctl restart ssh
sudo sshd -T | grep -i passwordauthenticationCode language: PHP (php)
Expected output of the last command: passwordauthentication yes. OpenSSH uses the first value it reads for each setting, and files in sshd_config.d are read before the rest of the main file. So you must edit the drop-in file that says no. Adding yes at the bottom of sshd_config has no effect.
Note: Wetty also accepts --ssh-key with a private key mounted into the container. Avoid this for anything internet-facing: anyone who can open the page gets a shell with no password.
Access and verify
- Check the container:
sudo docker ps --filter name=wetty. The originaldocker pswithoutsudofails with a socket permission error unless your user is in thedockergroup. The PORTS column should show0.0.0.0:80->3000/tcp. - Check locally on the instance:
curl -sI http://localhost/wettyshould returnHTTP/1.1 200 OK. - Open
http://<public-ip-or-dns>/wettyin a browser. The public IP and DNS name in the example above belong to one specific instance, so use your own from the EC2 console. - Enter the password set earlier. You should get a shell on the EC2 host. Confirm with
hostname: it should print the instance hostname (such asip-172-31-...), not a container ID. - If something fails, watch the logs:
sudo docker logs -f wetty.
To serve Wetty at / instead of /wetty, add --base=/ after the image name.
Secure it before exposing it
Over plain HTTP on port 80, the password you type travels unencrypted, and the login page is open to anyone who can reach the port. For anything beyond a short lab, put Nginx with TLS in front of Wetty and publish the container only on loopback with -p 127.0.0.1:3000:3000:
server {
listen 443 ssl;
server_name wetty.example.com;
ssl_certificate /etc/letsencrypt/live/wetty.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/wetty.example.com/privkey.pem;
location /wetty {
proxy_pass http://127.0.0.1:3000/wetty;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 1d;
}
}Code language: PHP (php)
- The
UpgradeandConnectionheaders are required. Without them the WebSocket fails and the terminal stays blank. - Open only 443 in the security group and limit the source to known IPs.
- Wetty can also serve TLS itself with
--ssl-keyand--ssl-cert(mount the files into the container). - For team access, put an identity-aware proxy in front, as described in the Pomerium tutorial, and keep strong passwords with fail2ban or equivalent on
sshd. - When you finish a lab, remove it:
sudo docker rm -f wetty, and close the security group rule.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Browser times out | Security group does not allow port 80, or the container is not running | Add an inbound rule for your IP; check sudo docker ps |
404 or blank page at / | Wetty serves under /wetty by default | Use /wetty or run with --base=/ |
Permission denied (publickey) | Ubuntu AMI disables password authentication | Enable it as shown above, or use a key |
Login prompt but you land in the container, or Connection refused | --ssh-host=127.0.0.1 points at the container | Use the private IP or host.docker.internal with --force-ssh |
Conflict. The container name "/wetty" is already in use | Earlier container still exists | sudo docker rm -f wetty, then run again |
Bind for 0.0.0.0:80 failed: port is already allocated | Another service uses port 80 | Stop it or map another port, for example -p 8080:3000 |
permission denied ... docker.sock | User is not in the docker group | Use sudo, or sudo usermod -aG docker $USER and log in again |
| Terminal loads but stays blank behind a proxy | WebSocket upgrade headers missing | Add the Upgrade/Connection headers shown above |
Frequently asked questions
Why does Wetty not load at the root URL?
Wetty serves its UI under the base path /wetty by default. Open http://host/wetty, or start the container with --base=/ to serve it at the root.
Why use the Docker image instead of npm install?
Installing Wetty globally with npm compiles native modules and depends on your Node.js version, so builds often fail. The wettyoss/wetty image already contains a working Node.js runtime and dependencies, so the host only needs Docker.
Is Wetty safe to expose on the public internet?
Not over plain HTTP with an open security group. Use TLS, restrict source IPs, use strong passwords or an identity-aware proxy, and never mount a private key that gives a shell without a password.
Can Wetty connect to servers other than the EC2 instance it runs on?
Yes. Set --ssh-host to any host the container can reach on its SSH port, such as another instance's private IP in the same VPC, as long as security groups allow port 22 from the Wetty instance.
Does the browser terminal need port 22 open to the internet?
No. The browser only talks to Wetty over HTTP or HTTPS. Wetty connects to SSH from inside the instance or VPC, so port 22 can stay closed to the internet.
Related tutorials
- Pomerium Tutorial: Complete End-to-End Guide to Zero-Trust Access, Identity-Aware Proxy, SSO, Kubernetes, SSH and Production Deployment
- How to Login to Linux Server using Putty?
- More Linux tutorials
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services โ all in one place.
Explore Hospitals
This article offers a clean, practical walkthrough for using Wetty to expose SSH sessions through a browserโa great fit for cloudโbased setups like AWSโฏEC2. It clearly lays out the prerequisites (installing Docker) and the container command (docker run โd โโname wetty โp 80:3000 wettyoss/wetty โโsshโhost=127.0.0.1) that avoids tedious Node/npmโbased installs. Besides the โhowโ, the article also points out useful details such as mapping host and container ports, using /wetty as the path, and verifying the container is running. For DevOps teams or interns building remote access or management workflows in a secure way, this tutorial bridges setup to usage extremely well.