-
-
Notifications
You must be signed in to change notification settings - Fork 912
Example Usage
ttyd starts web server at port 7681
by default, you can use the -p
option to change it, the command
will be started with arguments
as options. For example, run:
ttyd -p 8080 bash
Then open http://localhost:8080 with a browser, you will get a bash shell with debug mode enabled.
More Examples:
- If you want to login with your system accounts on the web browser, run
ttyd login
. - You can even run a none shell command like vim, try:
ttyd vim
, the web browser will show you a vim editor. - Sharing single process with multiple clients:
ttyd tmux new -A -s ttyd vim
, runtmux new -A -s ttyd
to connect to the tmux session from terminal.
- Sharing single docker container with multiple clients:
docker run -it --rm -p 7681:7681 tsl0922/ttyd
. - Creating new docker container for each client:
ttyd docker run -it --rm ubuntu
.
In order to have ttyd launch on startup and restart automatically on error, you can create and enable a service file running its binary. Say we've downloaded a binary from the releases page and moved it to /opt
(so its full path is now /opt/ttyd
). paste the following content into /etc/systemd/system/ttyd.service
:
[Unit]
Description=TTYD
After=syslog.target
After=network.target
[Service]
ExecStart=/opt/ttyd login
Type=simple
Restart=always
User=root
Group=root
[Install]
WantedBy=multi-user.target
Now, to start the service and make sure it starts on boot:
sudo systemctl start ttyd && sudo systemctl enable ttyd
MAKE SURE YOU DON'T RUN ANY COMMAND OTHER THAN login
AS ROOT, AND THAT YOUR ROOT ACCOUNT HAS NO PASSWORD. IF YOU CHOOSE TO RUN A DIFFERENT COMMAND, USE ANY NON-ROOT USER.