I have a remote host C accessible using telnet from host B. From the host A, I use ssh to create a port forward for access to the telnet server of the host C.

I use the following command at hostA

ssh  -n -l root <ip HostB> -L3015:<private ip hostC>:23 -N -t -t

With this command I can use telnet localhost 3015 to connect to telnet port of hostC, but depending the hostC model/device the telnet work line-by-line or character. I want to force telnet to work always in character mode.

I know that I can change the mode using telnet commands, but I need to force this mode without escape to telnet prompt (telnet>). I don't know if there is some kind of environ var to export or some flag/options to pass the telnet client (I don't see nothing at the man page).

Of course if I connect using telnet from Host A or Host B to Host C the telnet mode always is character (not line-by-line)


Not exactly following what you are trying to do...

However, you can specify telnet commands on a host by host basis, or set it for all hosts with the DEFAULT host, with your $HOME/.telnetrc or /etc/telnetrc files. See the 'open host' part of the telnet man page.

  • Finally I use the telnetrc to indicate to force the mode to character for localhost host (the telnet don't negotiate because the not standard port, as Gerald said) – eferro Oct 14 '09 at 20:02

It would be helpful if you let us know what telnet client or at least what OS you're using. On many systems if you telnet to a port other than 23 (or whatever "telnet" matches in /etc/services) the client won't do any sort of protocol negotiation. This is great for manually debugging an HTTP or POP server, but not so great in your case.

According to the telnet man pages on Linux, OS X, and Cygwin, putting a minus before the port number, e.g. telnet localhost -3015 should force negotiation on a nonstandard port. The man page on Solaris doesn't mention this. I have no idea what the standard Windows telnet client offers.

  • I am using a Ubuntu 9.04 and the normal telnet (/usr/bin/telnet.netkit, from telnet 0.17-36 deb) I reread the man page and you are right It said that I should use a dash to force the negociation, but at this point don't seems to work... – eferro Oct 14 '09 at 19:53
  • Finally I use the /etc/telnetrc but the problem is exactily as you descrive, but the dash didn't work for me (I try with and without scaping the dash character... ) Lot of thanks for the info – eferro Oct 14 '09 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.