How to Install WeTTY on OpenBSD

WeTTY is an SSH web terminal implementation. It allows a user to run commands on a remote server using a web browser. In this tutorial, we will learn how to install WeTTY on OpenBSD.

Prerequisites

  1. A working OpenBSD installation
  2. Root access to the server
  3. A web browser to access the web terminal

Steps

Step 1: Install Node.js

We will need Node.js to install WeTTY. To install Node.js in OpenBSD, execute the following command:

# pkg_add node

Step 2: Install WeTTY

WeTTY can be installed using npm, which is the package manager for Node.js. Execute the following command to install WeTTY:

# npm install -g wetty

Step 3: Configure WeTTY

Now that WeTTY is installed, we need to configure it to run as a service. To do this, create a wetty.service file in the /etc/rc.d/ directory:

# touch /etc/rc.d/wetty.service

Edit the file using your preferred text editor and add the following content:

#!/bin/sh

daemon="/usr/local/bin/node /usr/local/lib/node_modules/wetty/app.js -p 3000 --sslkey /etc/ssl/private/server.key --sslcert /etc/ssl/server.crt"
name="wetty"
rcvar=${name}_enable

command=${daemon}
pidfile="/var/run/${name}.pid"
command_args="-d -p 3000 --sslkey /etc/ssl/private/server.key --sslcert /etc/ssl/server.crt"

. /etc/rc.d/rc.subr

rc_start() {
        $command $command_args 2>&1 >/dev/null &
        echo ${!} > ${pidfile}
}

rc_stop() {
        kill `cat ${pidfile}` >/dev/null 2>&1
}

rc_reload() {
        rc_stop
        rc_start
}

rc_check() {
        if ! kill -0 `cat ${pidfile}` >/dev/null 2>&1; then
                echo "${name} not running, restarting"
                rc_start
        fi
}

rc_cmd $1

Step 4: Enable and start WeTTY service

Make the wetty.service file executable using the following command:

# chmod +x /etc/rc.d/wetty.service

Next, enable and start the WeTTY service by executing the following command:

# rcctl enable wetty.service && rcctl start wetty.service

Step 5: Access WeTTY

By default, WeTTY listens on port 3000. Open your web browser and navigate to the server's IP address or hostname followed by port number 3000 (e.g., https://192.168.0.1:3000/). You should see the login prompt for the web terminal.

Now, you can log in using SSH credentials and start running commands on the remote server using a web browser.

Conclusion

Installing WeTTY on OpenBSD is a straightforward process. We install Node.js, configure WeTTY to run as a service, and then enable WeTTY service to start automatically on boot. Once installed, we can access the web terminal using a web browser to run commands on the remote server.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!