Hey everyone,
I have a primitive shell script that displays some text and accepts user input. I would like to make this script available over telnet, at least within my LAN. Ideally, I want the user to be able to 'telnet 192.168.xx.xx' and be able to play the game. What is the best way to achieve this?
(I am aware of the security risks associated with telnet, this is simply an experiment within my LAN).
Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
[SOLVED] Serving a script over telnet
-
- Posts: 6
- Joined: 2022-05-03 04:46
- Has thanked: 1 time
[SOLVED] Serving a script over telnet
Last edited by Rockingcool on 2022-05-22 20:18, edited 1 time in total.
Re: Serving a script over telnet
Best is if you use ssh instead of telnet, so you can just:
$ ssh 192.168.xx.xx -t /path/to/your/script
The -t is needed to make sure ssh allocates a pseudo-terminal, so that interactive programs work as expected.
If you want to use telnet, or ssh but without having to give the path for the script, you could create a user (e.g. "game") at the server whose .profile (or .bashrc) runs the script.
This way telnet game@192.168.xx.xx or ssh game@192.168.xx.xx will directly run the script.
$ ssh 192.168.xx.xx -t /path/to/your/script
The -t is needed to make sure ssh allocates a pseudo-terminal, so that interactive programs work as expected.
If you want to use telnet, or ssh but without having to give the path for the script, you could create a user (e.g. "game") at the server whose .profile (or .bashrc) runs the script.
This way telnet game@192.168.xx.xx or ssh game@192.168.xx.xx will directly run the script.
-
- Posts: 6
- Joined: 2022-05-03 04:46
- Has thanked: 1 time
Re: Serving a script over telnet
This works exactly as expected, so thank you very much!
I have another question, although I'm unsure if I have to create another thread for this.
How do I run multiple telnet (or ssh) servers on different ports? The result should be something along these lines.
telnet 192.168.xx.xx 23 --> shell
telnet 192.168.xx.xx 2323 --> ASCII game
Thanks in advance.
I have another question, although I'm unsure if I have to create another thread for this.
How do I run multiple telnet (or ssh) servers on different ports? The result should be something along these lines.
telnet 192.168.xx.xx 23 --> shell
telnet 192.168.xx.xx 2323 --> ASCII game
Thanks in advance.
Last edited by Rockingcool on 2022-05-22 14:27, edited 1 time in total.
Re: Serving a script over telnet
The standard telnet server (in.telnetd) runs via inetd or xinetd (it is not a standalone server).
So I imagine you could setup xinetd (easier than inetd) with something like:
This would run, IIRC, telnet on port 23 as user "user1", and on port 2323 as user "user2", so that you could place the wanted program in the respective .profile for each user.
For sshd it's easier, I think, as you can just make multiple sshd.service entries, each with a custom configuration, and let systemd take care of that.
But I'm only guessing, I haven't tried whether what I've written works (or should work), so take that just as an idea for further research, from your side ;-)
So I imagine you could setup xinetd (easier than inetd) with something like:
Code: Select all
service 23
{
flags = REUSE
socket_type = stream
wait = no
user = user1
server = /usr/sbin/in.telnetd
log_on_failure += USERID
disable = no
}
service 2323
{
flags = REUSE
socket_type = stream
wait = no
user = user2
server = /usr/sbin/in.telnetd
log_on_failure += USERID
disable = no
}
For sshd it's easier, I think, as you can just make multiple sshd.service entries, each with a custom configuration, and let systemd take care of that.
But I'm only guessing, I haven't tried whether what I've written works (or should work), so take that just as an idea for further research, from your side ;-)
-
- Posts: 6
- Joined: 2022-05-03 04:46
- Has thanked: 1 time
Re: Serving a script over telnet
I will research this further, but your answer seems like a good starting point. Thank you very much!
I will mark this thread as solved.
I will mark this thread as solved.