In this tutorial, I describe how to access an SSH terminal in a web browser on Linux. Web-based SSH is useful when the firewall you are behind is so restrictive that only HTTP(s) traffic can get through.
Install Shell In A Box on Linux
To install shellinabox on Debian, Ubuntu or Linux Mint:
To install shellinabox on Fedora:
To install shellinabox on CentOS or RHEL, first enable EPEL repository, and then run:
Configure Shellinaboxd Web Server
By default shellinaboxd web server listens on 4200 TCP port on localhost. In this tutorial, I change the default port to 443 for HTTPS. For that, modify shellinabox configuration as follows.
Configure shellinaboxd On Debian, Ubuntu or Linux Mint:
# TCP port that shellinboxd's webserver listens on SHELLINABOX_PORT=443 # specify the IP address of a destination SSH server SHELLINABOX_ARGS="--o-beep -s /:SSH:192.168.1.7" # if you want to restrict access to shellinaboxd from localhost only SHELLINABOX_ARGS="--o-beep -s /:SSH:192.168.1.7 --localhost-only"
Configure shellinaboxd On Fedora, CentOS or RHEL:
# TCP port that shellinboxd's webserver listens on PORT=443 # specify the IP address of a destination SSH server OPTS="-s /:SSH:192.168.1.7" # if you want to restrict access to shellinaboxd from localhost only OPTS="-s /:SSH:192.168.1.7 --localhost-only"
Heads-up for Fedora users: According to the official document, some operations may not work out of the box when you run shellinaboxd in SELinux mode on Fedora. Refer to the document if you have any issue.
Provision a Self-Signed Certificate
During the installation of Shell In A Box, shellinaboxd attempts to create a new self-signed certificate (certificate.pem) by using /usr/bin/openssl if no suitable certificate is found on your Linux. The created certificate is then placed in /var/lib/shellinabox.
If no certificate is found in the directory for some reason, you can create one yourself as follows.
# cd /var/lib/shellinabox
# openssl genrsa -des3 -out server.key 1024
# openssl req -new -key server.key -out server.csr
# cp server.key server.key.org
# openssl rsa -in server.key.org -out server.key
# openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
# cat server.crt server.key > certificate.pem
Run Shellinaboxd Web Server
On Debian, Ubuntu or Linux Mint:
On Fedora, CentOS or RHEL:
$ sudo systemctl start shellinaboxd.service
To verify if shellinaboxd is running:
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 4787/shellinaboxd
Now open up your web browser, and navigate to https://<IP_address_of_SSH_server>. You should be able to see a web-based SSH console, and log in to the remote SSH server via web browser interface.
Subscribe to Xmodulo
Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.
Did you find this tutorial helpful? Then please be generous and support Xmodulo!
Latest posts by Dan Nanni (see all)
- How to monitor OpenFlow messages with packet sniffer - February 2, 2016
- How to search multiple pdf documents for words on Linux - January 13, 2016
- How to access Amazon Cloud Drive from the command line on Linux - January 12, 2016