MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

Wetty – How to Install & Access Wetty (Web-based SSH) on AWS EC2 linux to access using browser

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 with sudo dnf install -y docker and then sudo 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), not 0.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 run fail.

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-stopped brings Wetty back after a reboot or a Docker restart. The original command has no restart policy.
  • --force-ssh makes Wetty always use SSH, even if the target resolves to localhost.
  • --ssh-user=ubuntu skips 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

  1. Check the container: sudo docker ps --filter name=wetty. The original docker ps without sudo fails with a socket permission error unless your user is in the docker group. The PORTS column should show 0.0.0.0:80->3000/tcp.
  2. Check locally on the instance: curl -sI http://localhost/wetty should return HTTP/1.1 200 OK.
  3. Open http://<public-ip-or-dns>/wetty in 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.
  4. Enter the password set earlier. You should get a shell on the EC2 host. Confirm with hostname: it should print the instance hostname (such as ip-172-31-...), not a container ID.
  5. 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 Upgrade and Connection headers 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-key and --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

SymptomLikely causeFix
Browser times outSecurity group does not allow port 80, or the container is not runningAdd an inbound rule for your IP; check sudo docker ps
404 or blank page at /Wetty serves under /wetty by defaultUse /wetty or run with --base=/
Permission denied (publickey)Ubuntu AMI disables password authenticationEnable 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 containerUse the private IP or host.docker.internal with --force-ssh
Conflict. The container name "/wetty" is already in useEarlier container still existssudo docker rm -f wetty, then run again
Bind for 0.0.0.0:80 failed: port is already allocatedAnother service uses port 80Stop it or map another port, for example -p 8080:3000
permission denied ... docker.sockUser is not in the docker groupUse sudo, or sudo usermod -aG docker $USER and log in again
Terminal loads but stays blank behind a proxyWebSocket upgrade headers missingAdd 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

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals
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.

Related Posts

EC2 Key Pairs vs AWS Credentials: Practical Fixes for SSH and Security Group Setup

New EC2 users often confuse AWS API credentials with EC2 SSH key pairs, then get blocked by security group rules. This guide separates each concept and shows repeatable CLI and console steps to get instance access working safely.

Read More

Secure Connectivity from Public to Private: Introducing EC2 Instance Connect Endpoint

No more Bastion hosts!! AWS announces EC2 Instance Connect Endpoint, a new feature that allows you to connect securely to your instances and other VPC resources from…

Read More

How to login linux server of AWS from windows using putty?

How to Generate PPK file from PEM using PuttyGen? AWS by default do not allow accessing a linux server using password so only key is allowed. But…

Read More

Terraform Error: Key is not in valid OpenSSH public key format

Code Error Solutions: Rajesh Kumar I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best…

Read More

Example Terraform Code for AWS provider, resources aws_key_pair

This command would generate a public and private key $ ssh-keygen -f terraform_ec2_key This resources would import aws key pair Rajesh Kumar I’m Rajesh Kumar, a DevOps,…

Read More

Terraform Error: Failed to read ssh private key: no key found

Solutions private_key – The contents of an SSH key to use for the connection. These can be loaded from a file on disk using the file function….

Read More
Subscribe
Notify of
guest
2 Comments
Newest
Oldest Most Voted
Skylar Bennett
Skylar Bennett
1 year ago

This is a really practical and wellโ€‘written guide to setting up webโ€‘based SSH access with Wetty on AWS EC2 using Docker. I appreciate how the post walks through installing Docker, running the Wetty container, mapping ports (host port 80 to container port 3000), and then explains how to access the terminal via a browser โ€” that makes remote access much simpler and more accessible. The fact that this approach avoids needing Node.js/npm on the host and sidesteps common errors like โ€œgcโ€‘statsโ€ (by using the Docker image) makes the setup robust and easier to maintain. For DevOps engineers or anyone managing cloud servers who want quick, browser-based SSH access, this tutorial is a solid timeโ€‘saver and a good example of Dockerโ€‘first thinking. ๐Ÿ‘

Jason Mitchell
Jason Mitchell
1 year ago

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.

2
0
Would love your thoughts, please comment.x
()
x