SHELLINABOXD(1)

๐Ÿ“ฆ
version 2.21build3 ยท 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu questing

okay bestie, welcome to the shellinaboxd(1) manual page โ€” it's in the General Commands Manual section, and it's literally all about publishing a command line shell through an AJAX interface ๐Ÿ’…โœจ

โœจ NAME โœจ

shellinaboxd โ€” publish command line shell through AJAX interface ๐Ÿฆ‹


๐ŸŒธ SYNOPSIS ๐ŸŒธ

shellinaboxd
       [ -b | --background[=pidfile] ] [ -c | --cert=certdir ] [ --cert-
       fd=fd ] [ --css=filename ] [ --cgi[=portrange] ] [ -d | --debug ]
       [ -f | --static-file=url:file ] [ -g | --group=gid ] [ -h |
       --help ] [ --linkify=[none|normal|aggressive] ] [ --localhost-
       only ] [ --no-beep ] [ -n | --numeric ] [ --pidfile=pidfile ]
       [ -p | --port=port ] [ -s | --service=service ] [ -t | --disable-
       ssl ] [ --disable-ssl-menu ] [ -q | --quiet ] [ -u | --user=uid ]
       [ --user-css=styles ] [ -v | --verbose ] [ --version ]

๐Ÿ’– DESCRIPTION ๐Ÿ’–

so the shellinaboxd daemon is literally a webserver that listens on the port you tell it to. it publishes one or more services that show up in a VT100 emulator that's implemented as an AJAX web application. by default, the port is 4200 and the default service URL is http://localhost:4200/. ๐Ÿ’…

if you didn't ask for any particular service, the server launches /bin/login and asks for username and password, then starts the user's default login shell. ๐ŸŒธ

any modern browser with JavaScript and CSS enabled can access the published service, no extra plugins needed. periodt. โœจ


๐Ÿ‘‘ OPTIONS ๐Ÿ‘‘

the following command line parameters control the operation of the daemon:

  • -b, --background[=pidfile] โ€” launch shellinaboxd as a background daemon process. optionally, write the process id to pidfile. ๐Ÿฆ‹
  • -c, --cert=certdir โ€” if it was built with SSL/TLS support enabled, the daemon looks in certdir for any certificates. if you don't specify it, it defaults to the current working directory. ๐Ÿ’–
    • if the browser negotiated a Server Name Identification, the daemon looks for a matching certificate-SERVERNAME.pem file. this lets you virtually host multiple server names on the same IP address and port. slay.
    • if no SNI handshake happened, it falls back to using the certificate in the certificate.pem file.
    • the administrator should make sure there are matching certificates for each virtual host on this server, and that there's a generic certificate.pem file. ๐Ÿ‘‘
    • if no suitable certificate is installed, shellinaboxd will try to invoke /usr/bin/openssl and create a new self-signed certificate. this only works if, after dropping privileges, shellinaboxd has write permissions for certdir. no cap.
    • most browsers throw a warning when they see a self-signed certificate and then let the user accept it. because of that usability problem and the perceived security implications, auto-generated self-signed certificates are only meant for testing or intranet deployments. โš ๏ธ
  • --cert-fd=fd โ€” instead of giving a --cert directory, you can pass a filedescriptor fd where the certificate and key can be retrieved. this option disables SNI support, but it's a secure alternative for handing the private key data to the daemon. ๐Ÿ”
  • --css=filename โ€” sometimes you don't need to replace the whole style sheet with --static-file โ€” you just want a tiny incremental change to how the terminal looks. --css lets you append extra style rules to the end of the default styles.css sheet. you can give more than one --css option on the same command line. ๐Ÿ’…
  • --cgi[=portrange] โ€” instead of running shellinaboxd as a permanent process, you can demand-load it as a CGI web server extension. when you do that, it spawns a server that lives for the duration of the user's session. if you provide an optional portrange of the form MINPORT-MAXPORT, the server limits itself to those port numbers. they should be configured to pass through the firewall. ๐Ÿ”ฅ
--cgi is mutually exclusive with --background, --pidfile and --port. don't mix them, bestie.

in order to be useful as a CGI script, the shellinaboxd binary probably has to be made setuid-root. this is currently a discouraged configuration. use with care. ๐Ÿ’€

  • -d, --debug โ€” enables debugging mode, which means lots of log messages on stderr. this option is mutually exclusive with --quiet and --verbose. pick one, not all three. ๐Ÿ˜ญ
  • -f, --static-file=url:file โ€” the daemon serves various built-in resources from URLs underneath the service mount points. one or more --static-file options let you override these with your own external files. the url can be absolute or relative. absolute overrides exactly one built-in resource for one specific service; relative overrides resources for each defined service. ๐ŸŒˆ

these are the resources you can customize:

  • beep.wav โ€” audio sample that gets played whenever the terminal BEL is sounded.
  • favicon.ico โ€” favicon image file that shows up in the browser's navigation bar.
  • ShellInABox.js โ€” JavaScript file implementing the AJAX terminal emulator.
  • styles.css โ€” CSS style file that controls the visual appearance of the terminal.
  • print-styles.css โ€” CSS style file that controls the visual appearance of printed pages when using the VT100 transparent printing feature.

it is not recommended to override the root HTML page for a particular service. instead, move the service to an anonymous URL and serve a static-file that references the service in an <iframe>. ๐Ÿซถ

instead of a file, you can provide the name of a directory. this turns shellinaboxd into a simple web server that publishes all the files in that directory. this can help when publishing a more complex root HTML page. โœจ

  • -g, --group=gid โ€” when started as root, the server drops most privileges at start up. unless you override it with --group, it switches to nogroup. ๐Ÿ‘‘ when already running as an unprivileged user, group changes are not possible. ๐Ÿ™… if running with SSL/TLS support enabled, the certificates must be accessible to the unprivileged user and/or group that the daemon runs as. ๐Ÿ”
  • -h, --help โ€” shows a brief usage message with all the valid command line parameters. you love to see it. ๐Ÿ’–
  • --linkify=[none|normal|aggressive] โ€” the daemon tries to recognize URLs in the terminal output and make them clickable. this is not fool-proof โ€” you can get false negatives and false positives. by default, only URLs starting with a well-known protocol like http://, https://, ftp://, or mailto: are recognized. in aggressive mode, anything that looks like a hostname, URL or e-mail address is recognized, even without a protocol. ๐Ÿ˜ˆ
  • --localhost-only โ€” normally shellinaboxd listens on all available network interfaces. when you're behind a reverse-proxy, that's not always what you want. this option tells the daemon to only listen on the loopback interface. ๐Ÿ 
  • --no-beep โ€” audible signals are not it in some work environments, and browser media playback support is often buggy anyway. setting this suppresses all audio playback and enables the visual bell by default. ๐Ÿ”‡
  • -n, --numeric โ€” when running in --verbose mode, the daemon prints an Apache-style log file to stderr. by default, it resolves peer host names before logging them. DNS look-ups can be expensive, so you can request numeric IP addresses instead. ๐Ÿงฎ
  • --pidfile=pidfile โ€” you can configure the shellinaboxd daemon to store its process identifier in pidfile. ๐Ÿ“
  • -p, --port=port โ€” unless you override it with this option, the web server listens on port 4200 for incoming HTTP and HTTPS requests. ๐ŸŒ shellinaboxd can tell the difference between SSL/TLS requests and unencrypted requests. it also knows how to negotiate Server Name Identification, so you can use a single port for all types of requests even with virtual hosting. slay. โœจ
  • -s, --service=service โ€” you can register one or more services on different URL paths:
SERVICE := <url-path> ':' APPLICATION

there's a pre-defined application 'LOGIN' that makes the daemon invoke /bin/login, ask for username and password, and start the user's login shell. this is the default for the root user if no --service was defined. starting /bin/login requires root privileges. ๐Ÿ‘‘

there's another pre-defined application 'SSH'. instead of invoking /bin/login, it calls ssh. this is the default for unprivileged users if no --service was defined. it works for both privileged and regular users. if the optional host parameter is omitted, shellinaboxd connects to localhost. ๐Ÿ–ฅ๏ธ

alternatively, you can specify an application by giving a user description, a working directory, and a command line:

APPLICATION := 'LOGIN' | 'SSH' [ ':' <host> ] |  USER ':' CWD ':' CMD

the keyword 'AUTH' means the user information should be requested interactively instead of being part of the service description:

USER := 'AUTH' | <username> ':' <groupname>

the working directory can be an absolute path or the user's home directory:

CWD := 'HOME' : <dir>

the command that shellinaboxd executes can be the 'SHELL' keyword (the user's default login shell) or an arbitrary command line:

CMD := 'SHELL' : <cmdline>

the <cmdline> supports expansion of variables of the form ${VAR}. supported variables are:

  • ${columns} โ€” number of columns.
  • ${gid} โ€” numeric group id.
  • ${group} โ€” group name.
  • ${home} โ€” home directory.
  • ${lines} โ€” number of rows.
  • ${peer} โ€” name of remote peer.
  • ${realip} โ€” value of HTTP header field 'X-Real-IP'.
  • ${uid} โ€” numeric user id.
  • ${url} โ€” the URL that serves the terminal session.
  • ${user} โ€” user name.

quick lil heads-up bestie: this is still the --service tea from before, we're just picking up right where we left off ๐Ÿ’–

Okay so beyond the built-in env vars โ€” $TERM, $COLUMNS, $LINES, $SHELLINABOX_PEERNAME, $SHELLINABOX_REALIP and $SHELLINABOX_URL โ€” you can hand services any extra environment variables you want. How? Just stick space-separated variable assignments of the form KEY=VALUE in front of the <cmdline>. That's it, that's the whole trick. โœจ

And <cmdline> is polite about quoting: it understands single quotes and double quotes, plus backslashes for escaping characters, all in the familiar classic way. ๐Ÿซถ

tiny caution tho: when you're invoking shellinaboxd from a command line shell, you might need extra quoting so your shell doesn't gobble up and expand the variables before they ever reach the daemon. Your shell is nosy like that, ngl. ๐Ÿ™ˆ

If you don't explicitly ask for a --service at all, shellinaboxd defaults to attaching the default service to the root directory of the web server. For root, that's /bin/login, and for unprivileged users, it's ssh localhost. Which is literally the same as saying --service=/:LOGIN, or --service=/:SSH, respectively. ๐Ÿ’…

important: for the SSH service to work properly, you need a running ssh server on the local system with enabled password authentication. And if you're using the <host> parameter, those exact same conditions have to be true on that remote system too. No password auth, no vibes, no session. ๐Ÿ˜ญ

โœจ OPTIONS โœจ (the rest of the lineup, bestie ๐Ÿ’–)

  • -t, --disable-ssl โ€” By default, shellinaboxd redirects all incoming HTTP requests to their equivalent HTTPS URLs. But if promoting connections up to encrypted SSL/TLS sessions isn't the vibe you want, you can turn that behavior off. ๐Ÿšซ๐Ÿ”’ This option is also lowkey perfect for testing, or for deploying on trusted intranets where SSL certificates just... aren't available. ๐Ÿคทโ€โ™€๏ธ
  • --disable-ssl-menu โ€” If the user shouldn't be able to switch back and forth between HTTP and HTTPS modes, you can yeet that choice right out of the context menu. (They can still make that choice by going directly to the appropriate URL, though โ€” so it's more "out of sight" than "locked down", iykyk.)
  • -q, --quiet โ€” Suppresses all messages to stderr. Mutual exclusivity alert: this one is mutually exclusive with --debug and --verbose. Pick your fighter. โš”๏ธ
  • -u, --user=uid โ€” If started as root, the server drops privileges by changing to nobody โ€” unless you've overridden the uid with this option. ๐Ÿ‘‘โžก๏ธ๐Ÿ‘ค For more details, go read the description of the --group option.
  • --user-css=styles โ€” The visual appearance of the terminal emulator can be customized through user-selectable style sheets. These style sheets show up as options in the right-click context menu of the terminal emulator. ๐ŸŽ€

Style sheets make up either independently selectable on/off options, or multiple style sheets can be grouped together. When forming a group, only one member of the group can be active at any given time โ€” that's what powers multiple-choice options.

Multiple independent groups are separated by semicolons:

STYLES := GROUP { ';' GROUP }*

The members of a group are separated by commas:

GROUP := OPTION { ',' OPTION }*

Groups with exactly one member are used for options that can be independently turned on and off.

Options include a human readable label that'll be shown in the context menu, followed by the name of the CSS file. They also must include an indicator showing whether the option should initially be turned on or turned off. Within a group, exactly one option should be turned on:

OPTION := <label> ':' [ '-' | '+' ] <css-file>
heads up: the user's selection of options gets persisted in a cookie. Which means the default settings of options as passed on the command line only take effect the very first time the user visits the terminal emulator in their browser. On all subsequent visits, the user's preferences win. The cookie is the main character now. ๐Ÿช๐Ÿ‘‘
  • -v, --verbose โ€” Enables logging of an Apache-style log file to stderr. Mutual exclusivity again, bestie: this one is mutually exclusive with --debug and --quiet. ๐Ÿ’…
  • --version โ€” Prints the version number of the binary and exits. Short, sweet, iconic. โญ

๐Ÿ› ๏ธ CONFIGURATION ๐Ÿ› ๏ธ

There are no configuration files and no permanent settings for shellinaboxd. Nothing hiding in /etc, nothing to hunt down. Freeing, honestly. ๐Ÿฆ‹

A small number of run-time configuration options are available from a context menu that becomes available when you click the right mouse button. These options get persisted in a browser cookie. ๐Ÿช

Many sites already have a web server running and would like to integrate shellinaboxd into their existing site. This is most commonly done by means of a reverse-proxy entry for the main web server. For Apache, this would require adding an option such as:

<Location /shell>
    ProxyPass  http://localhost:4200/
    Order      allow,deny
    Allow      from all
</Location>

If you're using a different web server, go read that server's documentation on how to configure reverse proxy operations. Do your research, bestie, it's giving diligence. ๐Ÿ“šโœจ

When using a reverse proxy, the --localhost-only option would normally be enabled as well. In addition, --disable-ssl might also be considered, depending on the exact configuration details of the reverse proxy.


๐ŸŒธ EXAMPLES ๐ŸŒธ (the fun part, fr fr)

  • shellinaboxd โ€” Attaches a web-enabled login shell to https://localhost:4200/. If the user connected without SSL, the session will automatically be promoted. Unless SSL certificates can be found in the current directory, the daemon will automatically generate suitable self-signed certificates. And if the command was invoked by a non-root user, the daemon uses ssh instead of /bin/login for the session. Auto-magic, no cap. โœจ
  • shellinaboxd -t โ€” Attaches a web-enabled login shell to http://localhost:4200/ with SSL/TLS support disabled. Simple. Clean. Unencrypted but intentional. ๐Ÿ’…
  • shellinaboxd -t -f beep.wav:/dev/null โ€” Runs all services with the audible-bell permanently disabled. Silence is golden, bestie. ๐Ÿ”‡
  • shellinaboxd -s /:SSH:example.org โ€” The terminal connects to a ssh session on example.org. Off you go. ๐ŸŒ
  • shellinaboxd -t -s /:AUTH:HOME:/bin/bash โ€” Interactively request the user's name and password prior to launching a Bourne shell. This command can be run by unprivileged users. But if doing so, it only allows this particular user to log in. ๐Ÿ‘ค
  • shellinaboxd -c certificates -u shellinabox -g shellinabox โ€” If the certificates directory exists and is writable by the shellinabox user and group, self-signed SSL certificates will be generated in this directory. This might require creating an appropriately named user first. Running this command as root allows any user on the system to log in at http://localhost:4200/. Sessions will automatically be promoted to SSL/TLS. ๐Ÿ‘‘
  • shellinaboxd -t -s /:LOGIN -s /who:nobody:nogroup:/:w โ€” In addition to the login shell at http://localhost:4200, show a list of currently logged in users when accessing http://localhost:4200/who. This command must be run as root in order to be able to change to nobody:nogroup as requested by the service description. ๐Ÿ”
  • shellinaboxd -t -s '/:root:root:/:wy60 -c /bin/login' โ€” Instead of the standard ANSI/VT100 terminal, publish a Wyse 60โ„ข terminal. Again, this command should be run as root. ๐Ÿ–ฅ๏ธโœจ
  • shellinaboxd --css white-on-black.css โ€” Loads the white-on-black.css style sheet from the current directory and appends it to the built-in styles.css sheet. This causes the terminal to always render white text on a black background. Aesthetic. ๐Ÿ–ค
  • shellinaboxd --user-css Normal:+black-on-white.css,Reverse:-white-on-black.css โ€” Allow the user to select whether they want text to be rendered normally or in reverse video. This command line option adds a new entry to the right-click context menu. ๐ŸŽจ

๐Ÿ’€ DIAGNOSTICS ๐Ÿ’€

The daemon returns a non-zero exit code in case of failure. With the exception of a small number of common error cases that are handled explicitly, most errors result in printing a "Check failed" message. And no, bestie, that doesn't typically mean there's a bug in the program โ€” it's just its normal way of reporting errors. That's just how it talks. ๐Ÿ˜ญ

Common failure conditions are:

  • reusing a port that is already in use,
  • lack of sufficient privileges to run a service,
  • failure to find SSL/TLS certificates, and
  • failure to write newly generated certificates to the certification directory.

๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

chmod(1), last(1), login(1), sh(1), shells(5), openssl(1SSL), w(1), wy60(1), xterm(1).


๐Ÿ”’ SECURITY ๐Ÿ”’

The daemon uses privilege separation techniques to allow it to drop privileges early. It is aware of setuid flags and restricts some operations when launched as a setuid application. Responsible king behavior. ๐Ÿ‘‘

Despite these safety features, a bug could conceivably lead to a determined attacker gaining elevated privileges.

STRONGLY discouraged, bestie: it is therefore strongly discouraged to set the setuid flag on the binary. Like, don't. Seriously. ๐Ÿšซ๐Ÿ’€

The expected deployment would be from a system rc script launched by /sbin/init. For extra security, the --group and --user options should be used to change to a dedicated user. Extra layers, extra safe, that's the vibe. ๐Ÿซถ

๐Ÿ’– AUTHOR ๐Ÿ’–

Copyright (C) 2008-2010 by Markus Gutschke <markus@shellinabox.com>.

okay so bestie, legal time but make it cute ๐Ÿ’…

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. Slay.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. (yes the caps are screaming, it's legally required, not me being dramatic for once ๐Ÿ˜ญ)

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ๐ŸŽ€


โœจ the extra rights (yes there's more, stay with me) โœจ

In addition to these license terms, the author grants the following additional rights:

If you modify this program, or any covered work, by linking or combining it with the OpenSSL project's OpenSSL library (or a modified version of that library), containing parts covered by the terms of the OpenSSL or SSLeay licenses, the author grants you additional permission to convey the resulting work. Corresponding Source for a non-source form of such a combination shall include the source code for the parts of OpenSSL used as well as that of the covered work. ๐Ÿฆ‹

You may at your option choose to remove this additional permission from the work, or from any part of it.

If you would like to negotiate different licensing terms that are compatible for integration with other projects, please contact the author. (be polite, they're a real person ๐Ÿ’œ)

If the OpenSSL system libraries can be found at run-time, they will be invoked by shellinaboxd to provide SSL/TLS support. The OpenSSL and SSLeay licenses require the following notices:

This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org/)
This product includes cryptographic software written by Eric Young (eay@cryptsoft.com)

๐Ÿ› BUGS ๐Ÿ›

ngl bestie, this is the "it's not me, it's the browsers" section ๐Ÿ’€

Due to browser limitations, some features might not be available to users of all browers. (and yes, that's how it's spelled in the original, iconic typo, I'm keeping it fr fr ๐Ÿ˜Œ)

  • Konqueror does not allow for reliable interception of CTRL keys. If you press a key together with the CTRL modifier, it continues performing the browser's predefined behavior for this particular key combination. In most cases, it also fails to report the correct key to the terminal emulator. As a work-around, pressing both the CTRL and the WINDOWS key sometimes works. ๐Ÿ™ˆ
  • Some browsers, most notably IE on Windows, disallow interception of ALT keys and always interpret these keys as menu accelerators. As a work-around, many UNIX applications allow pressing ESC, instead of ALT. ๐Ÿ’…
  • When using non-US keyboard layouts, some browser do not allow for reliably determining shifted ALT keys. Please report these cases if they turn out to be a problem, as work-arounds might be possible. (they're being so nice about it ๐Ÿ˜ญ)
  • Access to the native clipboard is typically not possible. Instead, an internal clipboard accessible from the right-button context menu is used for all but IE. ๐Ÿ“
  • Some browsers restrict the number of concurrent connections to a server. This restricts how many AJAX terminals can be opened simultaneously. If this becomes a problem, users can typically reconfigure their browsers to raise the limit. ๐ŸŒˆ
  • There have been reports of the VLC plugin on Linux/x86_64 crashing Firefox when the browser page gets reloaded. Setting the --no-beep option eliminates all references to VLC and thus appears to work around this crash. ๐Ÿงš

and that's the whole page bestie!! you read all three parts, main character energy fr fr ๐Ÿ‘‘

This was SHELLINABOXD(1), dated Sep 11, 2010 โ€” so vintage, so iconic, we love a classic โญ no cap, go forth and shellinaboxd responsibly ๐Ÿซถ๐Ÿ’–

๐Ÿ“ฆ where this page comes from