# Connecting to a telnet server

## Rinkhals

I want to run some tests on a telnet server.

For this I want my Gentoo box to accept a telnet session.

I am fully aware of the dangers of using telnet and am also aware that I'm better off using ssh, but, for the purpose of these tests I just want to run a telnet server.

The problem is that after I connect to the Gentoo box it disconnects after 2 or 3 seconds.

I believe that this is because of PAM.

How can I get my server to run?

Many thanks,

Rinki.

----------

## tony-curtis

sounds more like a TCP wrappers issue to me at first blush.

do you have the "tcpd" USE flag set (for whichever telnetd)?

----------

## Rinkhals

Tony,

Thanks for the reply

>do you have the "tcpd" USE flag set (for whichever telnetd)?

No I just ran 'emerge netkit-telnetd' without additional arguments.

However, I have just run

```
USE="tcpd" emerge netkit-telnetd
```

But this has not changed the behaviour of the telnet server.  :Sad: 

----------

## tony-curtis

telnetd is usually handled by inetd, so what's in /etc/xinetd.d/telnetd ?  disable = yes, or no?

and is xinetd (a) emerge'd and (b) running?

you can also ask telnetd to tell you some things about what it's doing, e.g. from the command-line

```
in.telnetd -D report -debug 23
```

does a "one shot" telnet daemon.  When you telnet to localhost in another window you'll get some info that might help.

----------

## Rinkhals

> telnetd is usually handled by inetd, so what's in /etc/xinetd.d/telnetd ?  disable = yes, or no?

It was set on 'no': changed to yes.

> and is xinetd (a) emerge'd and (b) running?

xinetd has been started: /etc/init.d/xinetd restart

> in.telnetd -D report -debug 23

> does a "one shot" telnet daemon.  When you telnet to localhost in another window you'll get some info that might help.

Not sure I understand. Returns "telnetd: getpeername: Socket operation on non-socket"

Thanks.

----------

## tony-curtis

>> telnetd is usually handled by inetd, so what's in /etc/xinetd.d/telnetd ? disable = yes, or no?

> It was set on 'no': changed to yes.

Ahhh, so telnetd was enabled, but now you've turned it off.  Well, no matter for testing in the meanwhile...

[I don't think disable=Bool is a good idea, it's a double-negative and is confusing]

>> and is xinetd (a) emerge'd and (b) running?

> xinetd has been started: /etc/init.d/xinetd restart

OK

>> in.telnetd -D report -debug 23

>> does a "one shot" telnet daemon. When you telnet to localhost in another window you'll get some info that might help.

> Not sure I understand. Returns "telnetd: getpeername: Socket operation on non-socket"

Really?  Did you enter the whole command-line?  If you run in.telnetd on its own, that's the error message you'll get.  "-debug <port>" (as in the man page) does a 1-shot and runs the daemon manually.

----------

## Rinkhals

> Ahhh, so telnetd was enabled, but now you've turned it off.  Well, no matter for testing in the meanwhile...

So I change it back to 'no' then? It doesn't appear to make any difference to the behaviour, namely that it disconnects immediately after connecting.

I notice that there is an option in the file which says 'wait = no'. If I change this to 'yes' I get the following message just prior to the disconnection:

Get error [10054]: An existing connection was forcibly closed by the remote host.

> Really?  Did you enter the whole command-line?  If you run in.telnetd on its own, that's the error message you'll get.  "-debug <port>" (as in the man page) does a 1-shot and runs the daemon manually.

Sorry. Typo. (I had omitted the '-' in front of debug). It now returns:

telnetd: bind: Address already in use

OK, so I stop xinetd and then run in.telnetd and it works!

```
Connected!

Disconnected!

Connected!

Get error [10054]: An existing connection was forcibly closed by the remote host.

Disconnected!

Connected!

Get error [10054]: An existing connection was forcibly closed by the remote host.

Disconnected!

Connected!

Disconnected!

Connected!

Get error [10054]: An existing connection was forcibly closed by the remote host.

Disconnected!

Connected!

td: send do TERMINAL TYPE

td: send do TSPEED

td: send do XDISPLOC

td: send do NEW-ENVIRON

td: ttloop

td: ttloop read 3 chars

td: recv wont TERMINAL TYPE

td: ttloop

td: ttloop read 9 chars

td: recv wont TSPEED

td: recv wont XDISPLOC

td: recv wont NEW-ENVIRON

td: send will SUPPRESS GO AHEAD

td: send do ECHO

td: send do NAWS

td: send will STATUS

td: send do LFLOW

td: ttloop

td: ttloop read 3 chars

td: recv will ECHO

td: ttloop

td: ttloop read 9 chars

td: recv wont NAWS

td: recv dont STATUS

td: recv wont LFLOW

td: simulating recv

td: recv will ECHO

td: send dont ECHO

td: send will ECHO

td: Entering processing loop

Linux 2.6.22.18-co-0.7.3 (Frodo) (0)

Frodo login: 

td: netread 3 chars

td: recv wont ECHO

td: netread 6 chars

td: ptyflush 5 chars

dave

Password: 

td: netread 8 chars

td: ptyflush 7 chars

Last login: Thu Mar 19 05:47:17 PDT 2009 from 192.168.37.43 on pts/0

dave@Frodo ~ $ 

```

This is quite adequate for my tests.

Thanks very much, Tony!

Dave Coventry

----------

