Faking a telnet server with netcat.

May 20 2020

Let's say that you need to be able to access a server somewhere on your network.  This is a pretty common thing to do if you've got a fair amount of infrastructure at home.  But let's say that your computer, for whatever reason, doesn't have the horsepower to run SSH because the crypto used requires math that older systems can't carry out in anything like reasonable time.  This is a not uncommon situation for retrocomputing enthusiasts.  In the days before SSH we used telnet for this, but pretty much the entire Net doesn't anymore because the traffic wasn't encrypted, so anyone with a mind to eavesdrop could grab your login credentials to abuse later.  However, on a home network behind a firewall between systems you own it doesn't hurt to use once in a while.  Good luck finding systems that still package in.telnetd, though.  However, you can fake it with a tool called netcat.

First, you need a FIFO (first in, first out) that, as far as a Linux machine is concerned is a file that multiple processes can open to read and write.  Whenever something writes into a FIFO, everything reading from it gets whatever came in the other end.  As passing data goes the question is "how hard do you really need it to be," and FIFOs answer the question with "Not hard."  Linux boxen come with a tool called mkfifo that create them; uncreating them is as simple as deleting them like any other file.  This is the first step toward faking a telnet server: