We’ve all been there, right? You debug something, you try
telnet to see if a port is open, and now you’re stuck in a telnet session.
$ telnet 192.168.2.5 8080 Trying 192.168.2.5... Connected to 192.168.2.5. Escape character is '^]'. quit exit stop goaway
And the answer seems so obvious. It’s staring us right in the face!
Escape character is '^]'.
Good! There’s an escape sequence. This is like one of those text based adventure games. I can beat this!
$ telnet 192.168.2.5 8080 Trying 192.168.2.5... Connected to 192.168.2.5. Escape character is '^]'. ^] wha pleasequit aargh
So you carefully copy/paste the
^] text shown at the top. A caret and then a closing square bracket. That wasn’t too hard. But why isn’t this working?
Ah it turns out that
^ sign is a symbol. It represents the
CTRL button on the keyboard. It’s a key combination that I have to press.
This is where the text adventure turns the difficulty level way up. My keyboard doesn’t have a
] sign on it. 😱
It’s got all sorts of obscure markers though. What’s that
§ thing below the number 6? And how often do you need a
ù? Clearly one of those should’ve been a
But have no fear, there are hidden key combo’s. On Mac I can type
° and that produces
So the magic incantation to exit a telnet session has to be
°. That’s four (4) keys at the same time. Good thing we’ve been given 5 fingers! Something tells me the end-boss in this game is going to require 5 key combo’s.
$ telnet 192.168.2.5 8080 Trying 192.168.2.5... Connected to 192.168.2.5. Escape character is '^]'. ^] ffs LeTmEoUt! LEAVE BRITNEY ALONE!!
It’s a Unix system. I know this.
I bet that Jurassic Park girl knows how to quit a telnet session. I’ve only been managing Linux servers for 15 years, what the heck do I know?
OK Mattias, think. What are you missing in this game? You’re playing it in Belgium, but it was probably designed by someone from the US. Or Sweden.
What do those keyboards look like?
Aha, they do have a dedicated key for the
] symbol. Spoiled little brats.
On to the text adventure: the key I’m looking for appears to be 2 keys to the right of
P key. Good, let’s try!
$ telnet 192.168.2.5 8080 Trying 192.168.2.5... Connected to 192.168.2.5. Escape character is '^]'. ^] telnet> quit Connection closed.
I’ve won! I’ve beaten the end game! 🎉
Turns out, the magic key combination to exit a telnet session is
that one weird key 2 positions to the right of the P. Unless you’re on a German keyboard. Then it’s one position to the right of P, not two. Because obviously.
★☆☆☆☆ — Lousy text adventure game, does not work.
The cheatcodes to beat the exit-a-telnet-session game
Most text adventure games have cheatcodes. I’ll provide the same for the how to exit a telnet session text adventure. If you’re stuck and want to quit, but you don’t have a
] on your keyboard, try one of those.
- Dutch, Belgian:
- Finnish, Swedish, Norwegian, Danish:
- Canadian French:
Or get a keyboard with a dedicated button.
Create your own text adventure telnet game!
You can create your own levels of the
telnet game. Telnet allows you to set a custom escape character with the
This would be especially diabolical if you were to, say, create a system-wide alias for
telnet on all your servers to mess with your coworkers.
$ telnet -e x 192.168.2.5 8080 Trying 192.168.2.5... Connected to 192.168.2.5. Escape character is 'x'. x telnet> quit Connection closed.
-e parameter you can give it a sane escape value. Or you could try to make the combo even worse with an alias and reverse the square bracket.
$ alias telnet='telnet -e ['
I’m not saying I would do that.
Playing the text adventure game
If you want to play the text adventure, telnet to a known nameserver. They respond to port 53 via UDP and TCP (for large DNS replies). Depending on the nameserver version they’re running, they don’t immediately close the connection if you send it garbage inputs.
$ telnet ns1.nucleus.be 53