Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Listener message on port 23

I want to have a message to anyone that tries to telnet (port 23) to my server that they are connecting to the wrong port, then disconnects them.

Basically something like socat would be ideal, but I couldn't get it working. Needs to be a persistent service (forks), so it goes back to wait on port 23 after executing.

I thought something like:
sudo socat -u tcp-l:23,fork gopen:/home/ajross/message.txt


...but this doesn't display anything.
by

1 Answer

vishaljlf39
One approach using netcat:
while true; do nc -l -p 23 < /home/ajross/message.txt; done


This will run an infinite loop, using netcat listen for incoming connections, and spit out the contents of message.txt to anyone connecting (test with nc localhost 23).

Login / Signup to Answer the Question.