Bring Your Own Terminal: CLI-Games Over SSH
You can SSH into CLI-Games from a real Linux terminal: chess, mail, chat, reading and your saved files, served by a gateway that runs in 256 MB of memory.
So this is basically a story about how a cool distinguishing feature came to be. A player had a question, asked me, and we made it happen. That's how it works 'round these parts. If you'd like to put your stamp on CLI-Games, message frank, post in #suggestions, submit a bugreport, or email [email protected].
Bring Your Own Terminal: CLI-Games Over SSH
A player asked Frank whether they could log into CLI-Games from their actual Linux terminal. For a site that spends its whole life imitating a terminal inside a browser, that is about the best question anyone could ask. It was also a slightly awkward one, because the answer was no.
That changed quickly. The first commit of the SSH gateway landed on September 7, and by the evening of September 8 it had mail, chess, chat, signup and key login. The answer is yes now. Open a (real Linux) terminal and put your own username in:
ssh [email protected]
Sign in with your account password. If you don't have an account, you can make one without opening a browser:
ssh [email protected]
That asks for an email, a username and a password, then for the verification code we send to your inbox. If the connection drops before you type the code, ssh [email protected] picks up where you stopped. The plus sign is the detail I like most in the whole gateway. A CLI-Games username can't contain one, so +signup and +verify can never collide with somebody's account.
There was one more problem at the door. A person who mistypes a password gets Permission denied and nothing else, and a person without an account gets the same. So the server sends the standard SSH banner before it asks for anything, and the banner carries the signup command, the verify command and the address of the connection guide. You see it whether or not the login works. This is the whole banner, as the server sent it on November 17:
CLI-Games account access
New account: ssh [email protected]
Finish verification: ssh [email protected]
Connection help: https://www.cli-games.com/ssh
Once you are in, ssh-key add 'your-public-key' enrolls a public key, and from then on you can stop typing the password.
The same account, from another direction
The gateway keeps no copy of your account. Every command you type becomes a request to the same account services the website uses, so the mail, friends, saved home files and chess games you find are the ones you already had.
Chess is where this shows best. Type daily chess for the daily puzzle, or chess games to list your correspondence games and play game-id to sit down at one. A move made over SSH is waiting on the website, and a move made on the website is waiting over SSH. The website draws its board these days. Over SSH you get the ASCII board, which in a real terminal looks the way it was always meant to. One caveat: the SSH board doesn't refresh by itself, so if your opponent moves while you are looking at it, type board.
There is no computer opponent for chess over SSH. Keeping a chess engine running for each connected player was more than we wanted to pay for in a first release, so the computer plays tictactoe, which costs one small request per move.
Between moves there is the rest of the place. mail reads your inbox, message username starts a letter and irc lists the chat rooms you can join. wiki, news and wire bring the reading into your terminal, in a pager that scrolls and searches. friends, activity, leaderboard <game> and keys show you the community and your own progress. ls, cd, pwd, cat and less work on your saved home files, and ed edits them. Yes, ed. A fuller editor was on the table and Frank chose to keep the small line editor, which suits a connection where every keystroke makes a round trip.
Type help for the full list. It is shorter than what the browser terminal can do, and that is on purpose.
Why the list is short
In a browser, your own machine does most of the work. Over SSH, ours does: the server holds the connection open, reads every keystroke and draws every line. So the first features are the ones where a command does one bounded piece of work and stops. Reading a page, saving a file, sending a letter and taking a chess turn all fit that description.
What the gateway refuses to do matters as much. It doesn't create a Linux account for you, start a shell on the host or launch a process per visitor. It is one program that understands a fixed list of commands, running in a single container capped at 256 MB of memory and half a CPU core. A connection closes after 15 minutes without input, or after two hours in total, and an account can hold two connections at once.
Chat took the most care. The website has new messages pushed to it, and an SSH session has to ask for them. It asks every five seconds while a room is busy and slows to every fifteen when the room goes quiet. A message you send from SSH goes out through the same path as one sent from the website, so the people in the browser see it the usual way.
SSH access to these account services is free.
That said, if this feature gets any traction, we will add more support for it. Make sure to let me know if you are using it for real.
The rough edges
The first phone session felt laggy. Part of that was ours to fix: an avoidable transport delay on every keystroke. In a small before-and-after check from one Linux client in September, median typing echo went from about 256 milliseconds to about 127. That was six samples on one network, so treat it as a sign we fixed something and nothing more. Every keystroke still has to reach the server and come back.
Some things last only as long as the connection. Chess progress and saved files survive a reconnect. An unsent letter, an unsaved ed buffer and the tic-tac-toe board do not, so send or save before you disconnect. A letter that fails to send stays on screen for you to fix.
On a phone, an SSH client is no longer the only way in, because the iPhone app is on the App Store. We still like the SSH route best. A terminal site that you can reach from a terminal is the version of this project that makes the most sense.
Try it, type help, and tell us what is missing with message frank.