# help with telnet setup - closes immediately by foreign host

## m27315

I am trying to follow this Gentoo-Wiki HOWTO: http://gentoo-wiki.com/HOWTO_telnetd.  It is fairly straightforward, except the modern version of telnetd sucks in xinetd, not inetd, so a little translation is required.

My problem is that when I try to telnet into my new Gentoo telnet server, it is immediately closed without asking for password or anything, like so:

```
# telnet <my_gentoo_telnet_server>

Trying <IP_address>...

Connected to <my_gentoo_telnet_server>.

Escape character is '^]'.

Connection closed by foreign host.
```

Any guesses as to what is wrong?

Here is what I did, plus config files:

```
# emerge netkit-base

# emerge netkit-telnetd

# groupadd -g 300 telnetd

# useradd -u 300 -g 300 telnetd

# usermod -aG telnetd <my_user>

# /etc/init.d/xinetd restart
```

/etc/xinetd.conf

```
defaults

{

        log_type        = SYSLOG daemon info

        log_on_failure  = HOST

        log_on_success  = PID HOST DURATION EXIT

        only_from       = localhost

        cps             = 50 10

        instances       = 50

        per_source      = 10

        v6only          = no

        groups          = yes

        umask           = 002

}

includedir /etc/xinetd.d
```

/etc/xinetd.d/telnetd

```
service telnet

{

        flags           = REUSE

        socket_type     = stream

        wait            = no

        user            = telnetd

        server          = /usr/sbin/in.telnetd

        log_on_failure += USERID

        disable         = no

}
```

What am I missing?  I feel like it is something obvious...

----------

## m27315

Ok, I got it working.  Here's the simplified solution with updated config files (see below...).  In summary, there were two problems.  The defaults for xinetd only allow connections from localhost.  That line must be commented out.  With that fixed, you get a "Permission denied" error, like the Wiki mentions.  The problem here is that telnetd must be run as root.  The telnetd user (#300) does not have sufficient privileges, and I do not know how to grant it the appropriate permissions.  (It probably needs to be added to some group.)  So, you have to use root.

Procedure:

```
# emerge netkit-telnetd
```

Edit config files like so:

/etc/xinetd.conf

```
#

# This is the master xinetd configuration file. Settings in the

# default section will be inherited by all service configurations

# unless explicitly overridden in the service configuration. See

# xinetd.conf in the man pages for a more detailed explanation of

# these attributes.

defaults

{

# The next two items are intended to be a quick access place to

# temporarily enable or disable services.

#

#       enabled         =

#       disabled        =

# Define general logging characteristics.

        log_type        = SYSLOG daemon info

        log_on_failure  = HOST

        log_on_success  = PID HOST DURATION EXIT

# Define access restriction defaults

#

#       no_access       =

#       only_from       =

#       max_load        = 0

        cps             = 50 10

        instances       = 50

        per_source      = 10

# Address and networking defaults

#

#       bind            =

#       mdns            = yes

        v6only          = no

# setup environmental attributes

#

#       passenv         =

        groups          = yes

        umask           = 002

# Generally, banners are not used. This sets up their global defaults

#

#       banner          =

#       banner_fail     =

#       banner_success  =

}

includedir /etc/xinetd.d
```

/etc/xinetd.d/telnetd

```
service telnet

{

        flags           = REUSE

        socket_type     = stream

        wait            = no

        user            = root

        server          = /usr/sbin/in.telnetd

        log_on_failure += USERID

        disable         = no

}
```

Now, begin xinetd, which controls and begins telnet:

```
# /etc/init.d/xinetd restart
```

If all goes well, add it to your start-up procedure:

```
# rc-update add xinetd default
```

HTH

----------

