3

if I do

telnet host_ip port < /dev/null
Trying host_ip...
Connected to host_ip.
Escape character is '^]'.
Connection closed by foreign host.

By checking the wireshark, the client side sends tcp rst to the host side. Can anyone explain what happens exactly? Does telnet requires interactive mode?

pepero
  • 141
  • 2
  • 7
  • what use would there be for a telnet session with standard input closed? – thrig Feb 01 '18 at 16:01
  • well, get or redirect the output from the terminal server via telnet – pepero Feb 01 '18 at 18:06
  • what terminal? you closed the terminal (that is typically attached via standard input) – thrig Feb 01 '18 at 18:18
  • 2
    try yourself, it is easy to reproduce. "terminal server" is usually the console server to connecting rs-232 for embedded devices. google "terminal server", you have better idea. here we want to redirect the terminal server output via telnet. – pepero Feb 01 '18 at 19:19
  • you're not redirecting output, you're closing standard input. why are you closing standard input? – thrig Feb 01 '18 at 19:56
  • i am naming a use case that you are asking. and it makes sense that this use case does not require input. – pepero Feb 01 '18 at 20:03
  • well if you break the terminal then you're going to have to fake a terminal (see meuh's answer) – thrig Feb 01 '18 at 20:42

3 Answers3

2

Are you sure that TelNet service is running on linux machine? try this one

telnet localhost 23 (23 port of telnet)

or try to use netcat

Strepsils
  • 5,000
  • 10
  • 14
  • 2
    yes, if I run without closing the stdin (i.e. telnet ip port), it works fine. if you try, you will find it like this as well. i just do not know much about telnet, and need some details. – pepero Feb 01 '18 at 15:57
0

first you need to see the ubuntu system log with this command

sudo gedit /var/log/syslog

and if you will see this error "execv( /usr/sbin/tcpd ) failed: No such file or directory" then run this command

sudo apt-get install tcpd

it will solve your problem (if not then you need to search your system error on google)

0

Telnet is bidirectional, so when one end closes, it prompts the other end to close too. If you want to keep stdin open at the client you can use tools like expect to wrap the call inside a pty:

expect <<\!
spawn telnet host port
expect eof
!
meuh
  • 1,563
  • 10
  • 11