Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i am trying to write a telnet server without username/password function. does anyone know a tutorial on how to implement such function? the source code from inetutils seems complicated ... thanx
A telnet server can be as simple as a socket listening on an arbitrary port. Often, a telnet client is one of the tools used early in testing/debugging of a socket-based IP server application. In the 'usual' Linux telnet daemon, authentication is seconded to the 'login' program. See the telnetd manpage.
For a good primer on writing networking applications, see Beej's Guide to Network Programming
--- rod.
A telnet server can be as simple as a socket listening on an arbitrary port. Often, a telnet client is one of the tools used early in testing/debugging of a socket-based IP server application. In the 'usual' Linux telnet daemon, authentication is seconded to the 'login' program. See the telnetd manpage.
For a good primer on writing networking applications, see Beej's Guide to Network Programming
--- rod.
thanks a lot. i was thinking about sending a string and call system() to execute it. libevent and select() is a must-have next step.
at meantime, i still need to learn how to program daemon to throw back a shell to client. for telnet, i guess this happens after login and authentication are done. i thought some simple io redirection should do it, but dont know how.
any pointer is appreciated
i dont know nc very well (however, its functionality is well known...)
it doesnt seem to throw back a shell in client side, does it?
i want to learn how to program daemon to return a shell to a connected client.
Okay, now I'm confused. You say you don't want to use username + password entry, but you do still want authentication + login. Are you planning to launch your shell with the UID of the telnet daemon process?
Your daemon should be able to do something like fork() + exec() a shell, with the stdin and stdout file descriptors attached to the telnet server's socket. See Chapters 2 & 4 of Beej's Guide to Unix IPC for some explanation of how to do this. The daemon would then listen to the socket, and write all received data to the child shell's stdin pipe, and write to the socket anything read from the shell's stdout pipe.
Be advised that a telnet client might send interesting stuff to your server that you might not be expecting, as per RFC-854 ("TELNET"). For example, you might see these bytes upon connecting:
255 253 1
which means "IAC DO ECHO", or the client is requesting that you echo everything back it sends. You don't have to echo; you can respond:
255 252 1
which is "IAC WONT ECHO", and the client has to deal.
There's probably stuff I'm forgetting, but I think the simplest thing you can do is if you get:
"IAC DO xxx"
respond:
"IAC WONT xxx"
and if you get:
"IAC WILL xxx"
respond:
"IAC DONT xxx"
and if you get:
"IAC IAC"
convert it into a single byte of value 255 and don't respond with anything in particular.
But in to handle telnet clients in general, you'll need to at least do some basic processing of the telnet protocol.
I *think*. It's been years since I messed with writing telnet clients.
Okay, now I'm confused. You say you don't want to use username + password entry, but you do still want authentication + login.
sorry i didnt mean to confuse you. now i just want a remote shell; other functions may be implemented later, but not an issue now.
Are you planning to launch your shell with the UID of the telnet daemon process?
... i thought so. is this not good?
Your daemon should be able to do something like fork() + exec() a shell, with the stdin and stdout file descriptors attached to the telnet server's socket. See Chapters 2 & 4 of Beej's Guide to Unix IPC for some explanation of how to do this. The daemon would then listen to the socket, and write all received data to the child shell's stdin pipe, and write to the socket anything read from the shell's stdout pipe.
i am reading them now. interesting stuff. many thanks for the suggestion.
--- rod.
pls c above
Last edited by kusanagiyang; 10-02-2010 at 04:23 PM.
Be advised that a telnet client might send interesting stuff to your server that you might not be expecting, as per RFC-854 ("TELNET"). For example, you might see these bytes upon connecting:
255 253 1
which means "IAC DO ECHO", or the client is requesting that you echo everything back it sends. You don't have to echo; you can respond:
255 252 1
which is "IAC WONT ECHO", and the client has to deal.
There's probably stuff I'm forgetting, but I think the simplest thing you can do is if you get:
"IAC DO xxx"
respond:
"IAC WONT xxx"
and if you get:
"IAC WILL xxx"
respond:
"IAC DONT xxx"
and if you get:
"IAC IAC"
convert it into a single byte of value 255 and don't respond with anything in particular.
But in to handle telnet clients in general, you'll need to at least do some basic processing of the telnet protocol.
I *think*. It's been years since I messed with writing telnet clients.
cool stuff!
i am trying to connect to remote and open a remote shell though
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.