How to use the command "gotty" (with examples)
The “gotty” command allows you to share your terminal as a web application. With “gotty”, you can easily share the output of a command or give others write permission to interact with your terminal. Additionally, you can add basic authentication credentials to ensure only authorized users can access your terminal.
More information about “gotty” can be found on the GitHub repository: https://github.com/yudai/gotty .
Use case 1: Share result of command
Code:
gotty command
Motivation: You might want to share the output of a command with someone who doesn’t have access to your terminal. By using “gotty”, you can easily create a web application that displays the output of a specific command.
Explanation: In this use case, the “command” parameter should be replaced with the actual command you want to share. For example, if you want to share the output of the “ls” command, you would use the following command: gotty ls
.
Example output: When you run the command gotty ls
, a web server will be started and the output of the “ls” command will be displayed in your browser. You can share the URL of the web application with others, allowing them to see the result of the command in real-time.
Use case 2: Share with write permission
Code:
gotty -w shell
Motivation: Sharing your terminal with write permission can be useful when you want to collaborate with others or provide remote support. By using the “-w” flag, you allow other users to input commands and interact with your terminal remotely.
Explanation: In this use case, the “-w” flag is added to the “gotty” command. The “shell” parameter indicates the type of shell to use. You can replace it with your preferred shell, such as “bash” or “zsh”.
Example output: When you run the command gotty -w bash
, a web application will be created that allows others to input commands into your terminal remotely. Any commands they enter will be executed in your terminal, and the output will be displayed in their browser.
Use case 3: Share with credential (Basic Auth)
Code:
gotty -w -c username:password shell
Motivation: To ensure only authorized users can access your shared terminal, you can add basic authentication credentials using the “-c” flag. This is particularly useful when sharing sensitive information or granting remote access to privileged accounts.
Explanation: In this use case, the “-w” flag is used to allow write permission, and the “-c” flag is added to enable basic authentication. The “username:password” parameter should be replaced with the desired username and password combination.
Example output: When you run the command gotty -w -c admin:password bash
, a web application will be created that prompts users to enter a username and password before accessing your terminal. Only users who provide the correct credentials will be able to view and interact with your terminal.
Conclusion:
The “gotty” command is a versatile tool that allows you to share your terminal as a web application. Whether you want to share the output of a command, collaborate with others, or provide remote support, “gotty” provides the functionality to do so easily. By leveraging its various command-line options, you can customize the sharing experience to meet your specific needs.