GoTTY is a simple command line tool that turns your CLI tools into web applications.

Related tags

Command Line gotty
Overview

GoTTY - Share your terminal as a web application

All Contributors

GitHub release MIT License

GoTTY is a simple command line tool that turns your CLI tools into web applications.

Original work by Iwasaki Yudai. There would be no GoTTY without him. ❀️

Screenshot

Installation

From release page

You can download the latest stable binary file from the Releases page. Note that the release marked Pre-release is built for testing purpose, which can include unstable or breaking changes. Download a release marked Latest release for a stable build.

(Files named with darwin_amd64 are for Mac OS X users)

Homebrew Installation

You can install GoTTY with Homebrew as well.

$ brew install sorenisanerd/gotty/gotty

go get Installation (Development)

If you have a Go language environment, you can install GoTTY with the go get command. However, this command builds a binary file from the latest master branch, which can include unstable or breaking changes. GoTTY requires go1.9 or later.

$ go get github.com/sorenisanerd/gotty

Usage

Usage: gotty [options]  []

Run gotty with your preferred command as its arguments (e.g. gotty top).

By default, GoTTY starts a web server at port 8080. Open the URL on your web browser and you can see the running command as if it were running on your terminal.

Options

   --address value, -a value     IP address to listen (default: "0.0.0.0") [$GOTTY_ADDRESS]
   --port value, -p value        Port number to liten (default: "8080") [$GOTTY_PORT]
   --path value, -m value        Base path (default: "/") [$GOTTY_PATH]
   --permit-write, -w            Permit clients to write to the TTY (BE CAREFUL) (default: false) [$GOTTY_PERMIT_WRITE]
   --credential value, -c value  Credential for Basic Authentication (ex: user:pass, default disabled) [$GOTTY_CREDENTIAL]
   --random-url, -r              Add a random string to the URL (default: false) [$GOTTY_RANDOM_URL]
   --random-url-length value     Random URL length (default: 8) [$GOTTY_RANDOM_URL_LENGTH]
   --tls, -t                     Enable TLS/SSL (default: false) [$GOTTY_TLS]
   --tls-crt value               TLS/SSL certificate file path (default: "~/.gotty.crt") [$GOTTY_TLS_CRT]
   --tls-key value               TLS/SSL key file path (default: "~/.gotty.key") [$GOTTY_TLS_KEY]
   --tls-ca-crt value            TLS/SSL CA certificate file for client certifications (default: "~/.gotty.ca.crt") [$GOTTY_TLS_CA_CRT]
   --index value                 Custom index.html file [$GOTTY_INDEX]
   --title-format value          Title format of browser window (default: "{{ .command }}@{{ .hostname }}") [$GOTTY_TITLE_FORMAT]
   --reconnect                   Enable reconnection (default: false) [$GOTTY_RECONNECT]
   --reconnect-time value        Time to reconnect (default: 10) [$GOTTY_RECONNECT_TIME]
   --max-connection value        Maximum connection to gotty (default: 0) [$GOTTY_MAX_CONNECTION]
   --once                        Accept only one client and exit on disconnection (default: false) [$GOTTY_ONCE]
   --timeout value               Timeout seconds for waiting a client(0 to disable) (default: 0) [$GOTTY_TIMEOUT]
   --permit-arguments            Permit clients to send command line arguments in URL (e.g. http://example.com:8080/?arg=AAA&arg=BBB) (default: false) [$GOTTY_PERMIT_ARGUMENTS]
   --width value                 Static width of the screen, 0(default) means dynamically resize (default: 0) [$GOTTY_WIDTH]
   --height value                Static height of the screen, 0(default) means dynamically resize (default: 0) [$GOTTY_HEIGHT]
   --ws-origin value             A regular expression that matches origin URLs to be accepted by WebSocket. No cross origin requests are acceptable by default [$GOTTY_WS_ORIGIN]
   --term value                  Terminal name to use on the browser, one of xterm or hterm. (default: "xterm") [$GOTTY_TERM]
   --enable-webgl                Enable WebGL renderer (default: true) [$GOTTY_ENABLE_WEBGL]
   --close-signal value          Signal sent to the command process when gotty close it (default: SIGHUP) (default: 1) [$GOTTY_CLOSE_SIGNAL]
   --close-timeout value         Time in seconds to force kill process after client is disconnected (default: -1) (default: -1) [$GOTTY_CLOSE_TIMEOUT]
   --config value                Config file path (default: "~/.gotty") [$GOTTY_CONFIG]
   --help, -h                    show help (default: false)
   --version, -v                 print the version (default: false)

Config File

You can customize default options and your terminal (hterm) by providing a config file to the gotty command. GoTTY loads a profile file at ~/.gotty by default when it exists.

// Listen at port 9000 by default
port = "9000"

// Enable TSL/SSL by default
enable_tls = true

// hterm preferences
// Smaller font and a little bit bluer background color
preferences {
    font_size = 5
    background_color = "rgb(16, 16, 32)"
}

See the .gotty file in this repository for the list of configuration options.

Security Options

By default, GoTTY doesn't allow clients to send any keystrokes or commands except terminal window resizing. When you want to permit clients to write input to the TTY, add the -w option. However, accepting input from remote clients is dangerous for most commands. When you need interaction with the TTY for some reasons, consider starting GoTTY with tmux or GNU Screen and run your command on it (see "Sharing with Multiple Clients" section for detail).

To restrict client access, you can use the -c option to enable the basic authentication. With this option, clients need to input the specified username and password to connect to the GoTTY server. Note that the credentials will be transmitted between the server and clients in plain text. For more strict authentication, consider the SSL/TLS client certificate authentication described below.

The -r option is a little bit more casual way to restrict access. With this option, GoTTY generates a random URL so that only people who know the URL can get access to the server.

All traffic between the server and clients are NOT encrypted by default. When you send secret information through GoTTY, we strongly recommend you use the -t option which enables TLS/SSL on the session. By default, GoTTY loads the crt and key files placed at ~/.gotty.crt and ~/.gotty.key. You can overwrite these file paths with the --tls-crt and --tls-key options. When you need to generate a self-signed certification file, you can use the openssl command.

openssl req -x509 -nodes -days 9999 -newkey rsa:2048 -keyout ~/.gotty.key -out ~/.gotty.crt

(NOTE: For Safari uses, see how to enable self-signed certificates for WebSockets when use self-signed certificates)

For additional security, you can use the SSL/TLS client certificate authentication by providing a CA certificate file to the --tls-ca-crt option (this option requires the -t or --tls to be set). This option requires all clients to send valid client certificates that are signed by the specified certification authority.

Sharing with Multiple Clients

GoTTY starts a new process with the given command when a new client connects to the server. This means users cannot share a single terminal with others by default. However, you can use terminal multiplexers for sharing a single process with multiple clients.

Screen

After installing GNU screen, start a new session with screen -S name-for-session and connect to it with gotty in another terminal window/tab through screen -x name-for-session. All commands and activities being done in the first terminal tab/window will now be broadcasted by gotty.

Tmux

For example, you can start a new tmux session named gotty with top command by the command below.

$ gotty tmux new -A -s gotty top

This command doesn't allow clients to send keystrokes, however, you can attach the session from your local terminal and run operations like switching the mode of the top command. To connect to the tmux session from your terminal, you can use following command.

$ tmux new -A -s gotty

By using terminal multiplexers, you can have the control of your terminal and allow clients to just see your screen.

Quick Sharing on tmux

To share your current session with others by a shortcut key, you can add a line like below to your .tmux.conf.

# Start GoTTY in a new window with C-t
bind-key C-t new-window "gotty tmux attach -t `tmux display -p '#S'`"

Playing with Docker

When you want to create a jailed environment for each client, you can use Docker containers like following:

$ gotty -w docker run -it --rm busybox

Development

You can build a binary by simply running make. go1.16 is required.

To build the frontend part (JS files and other static files), you need npm.

Architecture

GoTTY uses xterm.js and hterm to run a JavaScript based terminal on web browsers. GoTTY itself provides a websocket server that simply relays output from the TTY to clients and receives input from clients and forwards it to the TTY. This hterm + websocket idea is inspired by Wetty.

Alternatives

Command line client

  • gotty-client: If you want to connect to GoTTY server from your terminal

Terminal/SSH on Web Browsers

  • Secure Shell (Chrome App): If you are a chrome user and need a "real" SSH client on your web browser, perhaps the Secure Shell app is what you want
  • Wetty: Node based web terminal (SSH/login)
  • ttyd: C port of GoTTY with CJK and IME support

Terminal Sharing

  • tmate: Forked-Tmux based Terminal-Terminal sharing
  • termshare: Terminal-Terminal sharing through a HTTP server
  • tmux: Tmux itself also supports TTY sharing through SSH)

License

The MIT License

Contributors

Thanks goes to these wonderful people (emoji key):


Iwasaki Yudai

πŸ’»

Soren L. Hansen

πŸ’»

Andrea Lusuardi

πŸ’»

Manfred Touron

πŸ’»

Stephan

πŸ’»

Quentin Perez

πŸ’»

jzl

πŸ’»

Fazal Majid

πŸ’»

Immortalin

πŸ’»

freakhill

πŸ’»

0xflotus

πŸ’»

Andy Skelton

πŸ’»

Artem Medvedev

πŸ’»

Blake Jennings

πŸ’»

Christian Jensen

πŸ’»

Christopher Wilkinson

πŸ’»

Cyrus

πŸ’»

David Horsley

πŸ’»

Jason Cooke

πŸ’»

Denis Korenevskiy

πŸ’»

Massimiliano Stucchi

πŸ’»

Mikhail f. Shiryaev

πŸ’»

Robert Bittle

πŸ’»

sebastian haas

πŸ’»

shoji

πŸ’»

Shuanglei Tao

πŸ’»

The Gitter Badger

πŸ’»

Jacob Zhou

πŸ’»

zyfdegh

πŸ’»

fredster33

πŸ’»

mattn

πŸ’»

Shinichi Goto

πŸ’»

ygit

πŸ’»

StΓ©phane

πŸ›

Pavol Rusnak

πŸ’»

Devan Lai

πŸ’»

This project follows the all-contributors specification. Contributions of any kind welcome!

Issues
  • What's new in this fork?

    What's new in this fork?

    What do I get from this version over the original version?

    P.s. Although the license doesn't require you to, you should still credit http://github.com/yudai/gotty since this repo isn't a linked fork

    opened by jpillora 4
  • WebGL rendering broken in Safari (14.1)

    WebGL rendering broken in Safari (14.1)

    What version of GoTTY are you using (gotty --version)?

    1.3.0

    What operating system and browser are you using?

    macOS 11.3 on Apple Silicon Safari 14.1

    What did you do?

    Just run gotty with any command. Safari does not show any characters, just the background color.

    What did you expect to see?

    Normal font rendering


    Running GOTTY_ENABLE_WEBGL=0 gotty top fixes the issue.

    It seems that WebGL is enabled by default despite the documentation says WebGL is disabled by default. I am opening second issue for this - https://github.com/sorenisanerd/gotty/issues/16

    opened by prusnak 3
  • REST API to execute bash scripts

    REST API to execute bash scripts

    Use case: I have a lot of scripts hanging around that glue two services together, ingest data into a database, scrape a page, etc. Usually if I want more interactivity I have to port the script to a Web server and HTML forms.

    It would be great if I could instead assign a script to a URL, so that I could send a POST or GET request to a gotty URL and spawn a process with URL parameters being ported to command line arguments. This could then redirect to an ephemeral URL for the specific process, so if it takes a long time I can come back to the URL to see what the script is doing. Additionally, if the script prompts for user input, the process could just hang until I visit the URL again to type in input. This way I can periodically check in on my scripts without having to use ssh and screen, and automate their execution using tools like curl or wget.

    opened by Nexuist 2
  • Bump nanoid from 3.1.23 to 3.2.0 in /js

    Bump nanoid from 3.1.23 to 3.2.0 in /js

    Bumps nanoid from 3.1.23 to 3.2.0.

    Changelog

    Sourced from nanoid's changelog.

    Change Log

    This project adheres to Semantic Versioning.

    3.2

    • Added --size and --alphabet arguments to binary (by Vitaly Baev).

    3.1.32

    • Reduced async exports size (by Artyom Arutyunyan).
    • Moved from Jest to uvu (by Vitaly Baev).

    3.1.31

    • Fixed collision vulnerability on object in size (by Artyom Arutyunyan).

    3.1.30

    • Reduced size for project with brotli compression (by Anton Khlynovskiy).

    3.1.29

    • Reduced npm package size.

    3.1.28

    • Reduced npm package size.

    3.1.27

    • Cleaned dependencies from development tools.

    3.1.26

    • Improved performance (by Eitan Har-Shoshanim).
    • Reduced npm package size.

    3.1.25

    • Fixed browserify support.

    3.1.24

    • Fixed browserify support (by Artur Paikin).
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • How to set font using custom HTML?

    How to set font using custom HTML?

    Ability to set custom font

    I don't like the default font in the terminal. I'd prefer to be able to set my own. I set the following to be my custom index.html file:

    <!doctype html>
    <html>
      <head>
        <title>{{ .title }}</title>
        <link rel="manifest" href="manifest.json">
        <link rel="icon" href="favicon.ico">
        <link rel="icon" href="icon.svg" type="image/svg+xml">
        <link rel="stylesheet" href="./css/index.css" />
        <link rel="stylesheet" href="./css/xterm.css" />
        <link rel="stylesheet" href="./css/xterm_customize.css" />
        <style>
          canvas, div {
            font-family: 'Comic Sans MS', 'Comic Sans', sans-serif !important;
            color: red;
          }
        </style>
      </head>
      <body>
        <div id="terminal"></div>
        <script src="./auth_token.js"></script>
        <script src="./config.js"></script>
        <script src="./js/gotty.js"></script>
      </body>
    </html>
    

    But that didn't set the font of the terminal. So, by modifying the HTML, what is the correct/working way to change the font used in the terminal.

    Although, when I do that, it does set the font of the dimensions that appear for a second when I open it to be in Comic Sans. However, I'm looking to change the font of the terminal.

    EDIT 1:

    I tried setting the config file to the following:

    title_format = "DEMO DEMO"
    preferences {
        font_size = 64
    }
    

    The title gets set, so I'm using the config fine, but I can't set the font size (or the font itself, either). Any ideas?

    opened by CoconutMacaroon 1
  • Add quiet flag to disable logging

    Add quiet flag to disable logging

    I recently installed gotty on my device, but got annoyed that it prints text every time someone connects, which displays the text in my tmux session. So I added a flag to completely disable all logging, which can be used once everything is setup correctly. I also tried to to wrap all the log calls in an if statement, but the HTTP Server uses log as well, so for 0 output you need to disable logging completely.

    opened by hardliner66 1
  • gotty bash can't input command

    gotty bash can't input command

    When file a bug report (see below for feature requests)

    Please answer these quesions for a bug report. Thanks!

    What version of GoTTY are you using (gotty --version)?

    gotty version latest

    What operating system and browser are you using?

    Linux kaisawind-z2 5.10.42-1-MANJARO #1 SMP PREEMPT Thu Jun 3 14:37:11 UTC 2021 x86_64 GNU/Linux
    
    Chrome Version 91.0.4472.77 (64 bitοΌ‰
    

    What did you do?

    ./gotty bash
    

    What did you expect to see?

    just like ttyd, can input commands in web

    What did you see instead?

    only show bash, nothing can be input

    When file a new feature proposal

    ./ttyd bash
    

    works well

    opened by kaisawind 1
  • how to support alpine Linux?

    how to support alpine Linux?

    When file a bug report (see below for feature requests)

    Please answer these quesions for a bug report. Thanks!

    What version of GoTTY are you using (gotty --version)?

    v1.3.0

    What operating system and browser are you using?

    Alpine Linux 3.13.5

    What did you do?

    I want to run gotty in alpine Linux, but failed.

    If possible, please provide the command you ran. ./gotty -w bash

    What did you expect to see?

    gotty run well in alpine Linux.

    What did you see instead?

    If possible, please provide the output of the command and your browser's console output. ./gotty: not found

    When file a new feature proposal

    Please provide an actual usecase that requires your new feature.

    opened by linyinli 1
  • Fix auth modes enabled by config file

    Fix auth modes enabled by config file

    Currently, you can set enable_basic_auth = true or enable_tls_client_auth = true in the config file, but unless you also provide a credential via -c or a TLS CA certificate via -tls-ca-crt on the command line, it will disable basic auth and TLS client auth because it overrides EnableBasicAuth and EnableTLSClientAuth based solely on the presence of CLI options.

    This fixes it so that the auth modes enabled by the config file are not disabled in the absence of the above CLI options.

    opened by devanlai 1
  • Tests fail for webtty

    Tests fail for webtty

    $ go test github.com/sorenisanerd/gotty/webtty
    # github.com/sorenisanerd/gotty/webtty [github.com/sorenisanerd/gotty/webtty.test]
    webtty/webtty_test.go:25:16: not enough arguments in call to New
    	have (pipePair)
    	want (Master, Slave, ...Option)
    webtty/webtty_test.go:42:14: dt.TTY undefined (type *WebTTY has no field or method TTY)
    webtty/webtty_test.go:80:16: not enough arguments in call to New
    	have (pipePair)
    	want (Master, Slave, ...Option)
    webtty/webtty_test.go:112:13: dt.TTY undefined (type *WebTTY has no field or method TTY)
    FAIL	github.com/sorenisanerd/gotty/webtty [build failed]
    FAIL
    
    opened by prusnak 1
  • WebGL is enabled by default, README and --help says it's off by default

    WebGL is enabled by default, README and --help says it's off by default

    See

    (default = true)

    https://github.com/sorenisanerd/gotty/blob/aa86a34b763db1dfe42b138fdc72ca6861ac7868/server/options.go#L34

    and

    (default = false)

    https://github.com/sorenisanerd/gotty/blob/aa86a34b763db1dfe42b138fdc72ca6861ac7868/README.md#L75

    gotty --help also shows:

       --enable-webgl                Enable WebGL renderer (default: false) [$GOTTY_ENABLE_WEBGL]
    

    Suggestion: either set it to false in options.go (when it's hard to fix https://github.com/sorenisanerd/gotty/issues/15) or set it to true in README.md (when it's easy to fix https://github.com/sorenisanerd/gotty/issues/15). Not sure how to fix the --help prompt.

    opened by prusnak 0
Releases(v1.4.0)
Owner
Soren L. Hansen
Soren L. Hansen
An open-source GitLab command line tool bringing GitLab's cool features to your command line

GLab is an open source GitLab CLI tool bringing GitLab to your terminal next to where you are already working with git and your code without switching

Clement Sam 2k Jun 25, 2022
Simple activity indicator for your command line tools.

Simple activity indicator for your command line tools.

Luca Sepe 1 Oct 22, 2021
A command line tool to prompt for a value to be included in another command line.

readval is a command line tool which is designed for one specific purposeβ€”to prompt for a value to be included in another command line. readval prints

Venky 0 Dec 22, 2021
wy : a set of command-line tools to test your container-based platform

wy wy (Abbreviation of Would You) is a set of command-line tools to test your container-based platform. ToC: Commands Deployment Monitoring Contributi

Yusuke Kuoka 2 Apr 30, 2022
git-xargs is a command-line tool (CLI) for making updates across multiple Github repositories with a single command.

Table of contents Introduction Reference Contributing Introduction Overview git-xargs is a command-line tool (CLI) for making updates across multiple

Gruntwork 599 Jun 26, 2022
git-xargs is a command-line tool (CLI) for making updates across multiple GitHub repositories with a single command

git-xargs is a command-line tool (CLI) for making updates across multiple GitHub repositories with a single command. You give git-xargs:

Maxar Infrastructure 1 Feb 5, 2022
Inotify-tools is a C library and a set of command-line programs providing a simple interface to inotify.

inotify-tools This is a package of some commandline utilities relating to inotify. The general purpose of this package is to allow inotify's features

null 2.6k Jun 22, 2022
MyApps is a universal command line tool for managing manually installed applications.

MyApps MyApps is a universal command line tool for managing manually installed applications. Disclaimer I wrote this tool over two long nights while p

Piotr Icikowski 3 Jan 9, 2022
Simple and complete API for building command line applications in Go

Simple and complete API for building command line applications in Go Module cli provides a simple, fast and complete API for building command line app

teris.io 108 Apr 24, 2022
A simple tool which you can use to move through your directories from the command line

Fe What is Fe ? Fe is a simple tool which you can use to move through your direc

Pranav Baburaj 8 Jan 1, 2022
Basic command line example using golang grpc client tools

This is a basic command line interface that demonstrates using the golang GRPC API. The API is reused between dishy and the wifi router, however both

null 35 Jun 18, 2022
Command-line tools for the FFS module.

Command-line tools for FFS The blobd tool defines a JSON-RPC service that implements the FFS blob store interface over various underlying key-value st

M. J. Fromberger 0 Jan 6, 2022
A Go library for building command line applications

gocmd A Go library for building command line applications. Features Advanced command line arguments handling Subcommand handling Short and long comman

Fatih Cetinkaya 56 Jun 7, 2022
Interactive prompt for command-line applications

promptui Interactive prompt for command-line applications. We built Promptui because we wanted to make it easy and fun to explore cloud services with

Manifold 4.9k Jun 26, 2022
Wordle-cli - play wordle in your command line

Wordle CLI Play Wordle in your command line! Screenshots Download You can downlo

Nimble Bun Works 44 Jun 15, 2022
A command line tool for simplified docker volume command built with go

dockervol A command line tool for simplified docker volume command built with go. Features: Remove anonymous volume (beta) Remove volume by matching n

Moh Achun Armando 0 Dec 18, 2021
Watch your favourite anime using the video player of your choice directly from the command line

anime-cli Watch your favourite anime using the video player of your choice direc

Ruben Dewitte 4 Feb 10, 2022
Mirror - Mirror is command line tool for mirroring a web page

mirror mirror is command line tool for mirroring a web page. Caution Do not abus

Yusuke Wada 10 May 29, 2022
Package command provide simple API to create modern command-line interface

Package command Package command provide simple API to create modern command-line interface, mainly for lightweight usage, inspired by cobra Usage pack

chenen 0 Jan 16, 2022