WEB terminal tool under Linux: ttyd

Ttyd, an open source lightweight web terminal tool, shares your terminal through the Web

Installation:

 wget  https://github.com/tsl0922/ttyd/releases/download/1.7.2/ttyd.x86_64 chmod +x ttyd.x86_64

Start:

 Direct Start:/ ttyd.x86_64 -p 8080 bash Start with account password:/ ttyd.x86_64 -p 8080 -c root:123456 bash

Set the service to start automatically after startup: (applicable to CentOS7)

 echo ' [UNIT] #Service description Description=Media wanager Service #Specifies that the service will be started after systemd finishes executing those targets After=network.target [Service] #Define the running type of the service Type=simple #Program working directory WorkingDirectory=/root/ #PID file PIDFile=/run/test.pid #Specifies to load a file containing the list of environment variables required by the service. Each line in the file is the definition of an environment variable. EnvironmentFile=-/etc/test #Define the execution method of systemctl start | stop | reload *. service (the specific command needs to write an absolute path) #Note: ExecStartPre is the command executed before startup ExecStartPre=/usr/bin/test "x${NETWORKMANAGER}" = xyes ExecStart=/root/ttyd.x86_64 -p 8080 -c root:123456 bash ExecReload= ExecStop= #Create private temporary memory space PrivateTmp=True #Maximum File Openings LimitNOFILE=1048576 [Install] #Multi user WantedBy=multi-user.target '> /usr/lib/systemd/system/tty.service systemctl daemon-reload systemctl start tty systemctl enable tty

Options:

 OPTIONS: -p, --port              Port to listen (default: 7681,  use `0` for random port) -i, --interface         Network interface to bind (eg: eth0), or UNIX domain socket path (eg: /var/run/ttyd.sock) -c, --credential        Credential for Basic Authentication (format: username:password) -u, --uid               User id to run with -g, --gid                Group id to run with -s, --signal            Signal to send to the command when exit it (default: 1, SIGHUP) -a, --url-arg           Allow client to send command line arguments in URL (eg:  http://localhost:7681?arg=foo&arg=bar ) -R, --readonly           Do not allow clients to write to the TTY -t, --client-option     Send option to client (format: key=value),  repeat to add more options -T, --terminal-type      Terminal type to report, default: xterm-256color -O, --check-origin       Do not allow websocket connection from different origin -m, --max-clients       Maximum clients to support (default: 0, no limit) -o, --once               Accept only one client and exit on disconnection -B, --browser            Open terminal with the default system browser -I, --index              Custom index.html path -b, --base-path         Expected base path for requests coming from a reverse proxy (eg: /mounted/here, max length: 128) -P, --ping-interval     Websocket ping interval(sec) (default: 300) -6, --ipv6              Enable IPv6 support -S, --ssl               Enable SSL -C, --ssl-cert           SSL certificate file path -K, --ssl-key           SSL key file path -A, --ssl-ca             SSL CA file path for client certificate verification -d, --debug             Set log level (default: 7) -v, --version            Print the version and exit -h, --help               Print this text and exit

Note: Please modify the ttyd.x86_64 path after ExecStart. By default, the script exists in/root/and port 8080 is not occupied.

Server one-way authentication (please provide your own certificate):

 ./ttyd --ssl --ssl-cert server.crt --ssl-key server.key bash

For Nginx reverse proxy, please configure and add the following ws parameter:

 proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection upgrade; proxy_read_timeout 3600

Download the latest version:

 https://github.com/tsl0922/ttyd/releases

Original article by Mo Tao, if reproduced, please indicate the source: https://imotao.com/6918.html

fabulous (0)
 Head of Mo Tao Mo Tao
Previous November 20, 2022
Next November 20, 2022

Related recommendations

Post reply

Your email address will not be disclosed. Required items have been used * tagging

This site uses Akismet to reduce spam comments. Learn how we handle your comment data