How to use the command 'gotty' (with examples)
The gotty
command offers a unique and versatile solution for sharing your terminal as a web application. Developed to facilitate remote access to terminal sessions, gotty
provides customizable sharing options, which allow users to share terminal output over the web securely and efficiently. It is particularly useful for collaboration, demonstrations, and real-time monitoring, as well as educational or support purposes.
Use case 1: Share result of command
Code:
gotty command
Motivation:
Using gotty
to share the result of a command is especially useful when you need to exhibit the output of a specific command execution to others without granting direct access to your machine. This can be vital in a collaborative environment where team members might need to verify the results of a script or command in real time, such as during developer demonstrations or system administrative tasks.
Explanation:
gotty
: This is the base command that launches the application, allowing users to access terminal sessions via a web interface.command
: This specifies the command whose output you want to share. It could be any command you execute in a regular terminal.
Example Output:
When executed, gotty command
will start a web server, and the terminal session running the specified command will be accessible via a URL provided in the output. For instance, if you run gotty ls
, the URL might look like http://127.0.0.1:8080
, where any connected client can view the result of the ls
command in real-time through their web browser.
Use case 2: Share with write permission
Code:
gotty -w shell
Motivation:
Sharing a terminal session with write permission is particularly valuable when collaboration is necessary. It allows multiple users to interact with and modify the terminal session, which can be useful for pair programming, remote debugging, or collaborative scripting where multiple participants need to have direct input capabilities.
Explanation:
gotty
: The command to start the web-based terminal sharing.-w
: This flag enables write functionality, allowing users to interact with the session, not just observe it.shell
: Specifies the shell environment to be shared (e.g.,bash
,zsh
).
Example Output:
Executing this command will provide a URL, just like the previous example, but this time any users visiting the URL will be able to execute commands within the shared terminal session. For instance, accessing the URL http://127.0.0.1:8080
would present a fully interactive shell through the web interface.
Use case 3: Share with credential (Basic Auth)
Code:
gotty -w -c username:password shell
Motivation:
Adding a layer of security by requiring a username and password is essential when sharing terminal sessions across potentially untrusted networks or with users who should have authenticated access. This ensures that only authorized users can interact with the terminal, providing peace of mind when sharing access to sensitive systems or information.
Explanation:
gotty
: Initiates the terminal sharing application.-w
: Enables write permissions, allowing for interactive sessions.-c username:password
: This option sets up basic authentication, prompting users to input the specified credentials (‘username’ and ‘password’) before gaining access to the terminal session.shell
: Designates the shell environment to be shared.
Example Output:
Running this command creates a secure access point with a URL similar to http://127.0.0.1:8080
. Users attempting to connect will be required to enter the username and password specified in the command. Only upon successful authentication will they be able to observe or interact with the terminal environment.
Conclusion:
The gotty
command delivers a versatile approach to sharing terminal sessions over the web, offering ease of use and robust flexibility. Through its various options, users can choose how much access to grant, providing merely observational capabilities or full interactive permissions, and ensuring security with authentication where necessary. It is an invaluable tool for anyone needing to demonstrate, collaborate, or provide support remotely.