I tried to establish a telnet connection between my Windows 11 machine and my NixOS machine, but it said “could not establish connection, connection timed out” kind of message on puTTY which I used on the Windows 11 side.
I used the following on NixOS.
nix shell nixpkgs#busybox
sudo telnetd -F
On the Windows 11 side, I simply used puTTY to connect to the NixOS machine on port 23 using telnet.
The error says
Network error: Connection timed out
What am I doing wrong?
PS: Both machines are connected to the same router via ethernet cable, and I checked the IP of my NixOS telnet server using ip a before connecting with puTTY on Windows 11.
On the NixOS machine you would want to run the telnetd command (e.g., sudo telnetd -F), not telnet. You connect to a telnet server with the command telnet, you start the telnet daemon on a server with telnetd.
With that out of the way, it sounds like a puTTY configuration or networking error. I have no issues connecting to the busybox telnet daemon running on my NixOS host which was started with sudo telnetd -F. I did notice I have to specify a program to run at login otherwise it just closes the connection after successfully connecting.
The only other thing I can think of is that NixOS enables the firewall by default, have you either disabled the firewall on the NixOS machine or poked a hole in it to allow port 23?
I have the firewall TCP port 23 opened when I check my current config with nix repl '<nixpkgs/nixos>'.
Here is the value I get for the currently open ports.
I tried to explicitly mark it open in my configuration.nix, then sudo nixos-rebuild switch, then running a new terminal and the telnet server.
This time, I tried to connect from my smartphone with the Termius app, and interestingly enough, the error now is error: connection reset by peer.
Which is strange, because it does sound like a port blocked from server side, right?
Maybe I should tell the background of this issue. I wanted to setup an SSH connection between my Windows 11 and NixOS PCs, so I thought of sending my Windows 11 SSH pubkey over telnet to the NixOS PC. Turns out to be harder than I thought, so I ended up using the SneakerNet ( ;D ) instead.
But still, it’d be cool to setup telnet which I’ve never used.
I checked the router settings like address translations but nothing telling me the 23 is blocked.
If nothing works, I may try a different approach which is to set up a telnet server on Windows 11 and connect from NixOS.
I believe you got it working by opening the port as the message error: connection reset by peer is what telnetd returns when you connect successfully but haven’t specified a login command. Try launching the server with something like sudo telnetd -F -l bash but be aware that will connect to a root bash shell.