telnet can't connect to localhost [solved]

Using applications, configuring, problems
Post Reply
Message
Author
Saladin
Posts: 94
Joined: Sun 28 Aug 2011, 03:19

telnet can't connect to localhost [solved]

#1 Post by Saladin »

I know, ssh is more secure. But I'm testing a MUD codebase, so ssh won't work. Besides, the computer is not connected to the internet, so I'm not particularly worried about security.

Anyway, I keep getting an error message:

Code: Select all

telnet: Can't connect to remote host (127.0.0.1): Connection refused
I'm on Lupu 5.2.8.
Last edited by Saladin on Sat 08 Mar 2014, 14:31, edited 1 time in total.

User avatar
Semme
Posts: 8399
Joined: Sun 07 Aug 2011, 20:07
Location: World_Hub

#2 Post by Semme »

Hey, if that message was spit out by the BusyBox telnet, you should grab the real deal in PPM >> inetutils.
Last edited by Semme on Tue 04 Mar 2014, 21:53, edited 1 time in total.

User avatar
trapster
Posts: 2117
Joined: Mon 28 Nov 2005, 23:14
Location: Maine, USA
Contact:

#3 Post by trapster »

Are you running a telnet server? Try it after running telnetd.
trapster
Maine, USA

Asus eeepc 1005HA PU1X-BK
Frugal install: Slacko
Currently using full install: DebianDog

Saladin
Posts: 94
Joined: Sun 28 Aug 2011, 03:19

#4 Post by Saladin »

Thanks guys! Still can't get it working though.

I got inetutils-1.4.1. Tried to make a pet package of it (because the computer I'm working on can't 'make'). When I installed the package, and checked root/.packages, it looked like the package hadn't installed a single file. So I thought I'll just make install on the other computer, and copy the files over via disk.

Make install gives me this:

Code: Select all

Making install in headers
make[1]: Entering directory `/tmp/inetutils-1.4.1/headers'
make[2]: Entering directory `/tmp/inetutils-1.4.1/headers'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/tmp/inetutils-1.4.1/headers'
make[1]: Leaving directory `/tmp/inetutils-1.4.1/headers'
Making install in libinetutils
make[1]: Entering directory `/tmp/inetutils-1.4.1/libinetutils'
source='ttymsg.c' object='ttymsg.o' libtool=no \
	depfile='.deps/ttymsg.Po' tmpdepfile='.deps/ttymsg.TPo' \
	depmode=gcc3 /bin/sh ../depcomp \
	gcc -DHAVE_CONFIG_H -I. -I. -I.. -DPATH_WTMPX=\"/usr/local/var/log/wtmpx\"    -I../include    -g -O2 -c `test -f 'ttymsg.c' || echo './'`ttymsg.c
ttymsg.c: In function 'ttymsg':
ttymsg.c:135: error: lvalue required as left operand of assignment
make[1]: *** [ttymsg.o] Error 1
make[1]: Leaving directory `/tmp/inetutils-1.4.1/libinetutils'
make: *** [install-recursive] Error 1
Attempting to copy does this:

Code: Select all

Copying /tmp/inetutils-1.4.1/include/glob.h as /mnt/sdc1/inetutils-1.4.1/include/glob.h
ERROR: Operation not permitted
Copying /tmp/inetutils-1.4.1/include/fnmatch.h as /mnt/sdc1/inetutils-1.4.1/include/fnmatch.h
ERROR: Operation not permitted
Copying /tmp/inetutils-1.4.1/include/crypt.h as /mnt/sdc1/inetutils-1.4.1/include/crypt.h
ERROR: Operation not permitted
Copying /tmp/inetutils-1.4.1/include/arpa as /mnt/sdc1/inetutils-1.4.1/include/arpa
Copying /tmp/inetutils-1.4.1/include/arpa/telnet.h as /mnt/sdc1/inetutils-1.4.1/include/arpa/telnet.h
ERROR: Operation not permitted
Copying /tmp/inetutils-1.4.1/include/arpa/ftp.h as /mnt/sdc1/inetutils-1.4.1/include/arpa/ftp.h
ERROR: Operation not permitted
Copying /tmp/inetutils-1.4.1/include/arpa/tftp.h as /mnt/sdc1/inetutils-1.4.1/include/arpa/tftp.h
ERROR: Operation not permitted
Copying /tmp/inetutils-1.4.1/include/protocols as /mnt/sdc1/inetutils-1.4.1/include/protocols
Copying /tmp/inetutils-1.4.1/include/protocols/talkd.h as /mnt/sdc1/inetutils-1.4.1/include/protocols/talkd.h
ERROR: Operation not permitted
Copying /tmp/inetutils-1.4.1/include/tftpsubs.h as /mnt/sdc1/inetutils-1.4.1/include/tftpsubs.h
ERROR: Operation not permitted
I installed this package, which at least gives me a different kind of error. Now, instead of this

Code: Select all

telnet: Can't connect to remote host (127.0.0.1): Connection refused
it says

Code: Select all

Trying 127.0.0.1.
Connected to 127.0.0.1.
Escape character is '^]'.
Then after several seconds, I get

Code: Select all

Connection closed by foreign host. 
and it returns my prompt.

npierce
Posts: 858
Joined: Tue 29 Dec 2009, 01:40

#5 Post by npierce »

What does /etc/hosts.allow look like?

Code: Select all

cat /etc/hosts.allow

Saladin
Posts: 94
Joined: Sun 28 Aug 2011, 03:19

#6 Post by Saladin »

At the moment:

Code: Select all

ALL: LOCAL
I've changed it a few times based on suggestions from google, but it doesn't seem to make a difference in this instance. I still get the same "Connection closed by foreign host. "

npierce
Posts: 858
Joined: Tue 29 Dec 2009, 01:40

#7 Post by npierce »

That looks good, assuming you are still trying 127.0.0.1 or localhost.

Using Lupu 5.2.8.6-20140106 and the Inetd-Telnet.pet package you linked to in your previous post, I do get a login prompt, and can login.

Code: Select all

# telnet 127.0.0.1
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.

Linux 2.6.33.2 (localhost) (2)

puppypc login:
Do you still get these lines?:

Code: Select all

Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
If I break /etc/hosts-allow I see the behaviour you described. But yours looks fine, so I'm not sure what else to suggest.

Perhaps some other change to Lupu has interfered with things. Have you considered booting with a pristine Lupu (no save file) by entering puppy pfix=ram at the boot: prompt, then reinstalling the Inetd-Telnet.pet and restarting inetd?

Saladin
Posts: 94
Joined: Sun 28 Aug 2011, 03:19

#8 Post by Saladin »

Just tried booting without the save file, and it connects me to the login prompt, just like you said. Thank you very much for that. :D

But booting from the save file on two different computers still gives me this:

Code: Select all

Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Connection closed by foreign host. 
It's strange. I thought maybe it was an installed package interfering, so I just installed every package I have on the one computer into my pristine Lupu, and it still connects just fine.

So I can just transfer all my files over to a new save file and I'm set. I'm a little worried that it will just happen again, but I guess if that does happen, I'll have a better idea what causes it.

npierce
Posts: 858
Joined: Tue 29 Dec 2009, 01:40

#9 Post by npierce »

You're welcome. Glad to hear you got it going, even though the reason that there was a problem is still a mystery.

If you still have the old save file, trying to connect and failing, then running this command might or might not provide a clue:

Code: Select all

grep telnetd /var/log/messages | tail
But if you are happy with your new save file, don't bother. Sometimes it is best to leave an obsolete mystery unsolved and move on.

Saladin
Posts: 94
Joined: Sun 28 Aug 2011, 03:19

#10 Post by Saladin »

I haven't created a new savefile yet. I've been running low on hard drive space, so I want to be sure to backup everything first.

And I do want to know what causes this, just to be sure it won't happen again.

Code: Select all

sh-4.1# grep telnetd /var/log/messages | tail
Mar  5 22:40:13 puppypc authpriv.warn in.telnetd[732]: refused connect from 127.0.0.1 (127.0.0.1)

npierce
Posts: 858
Joined: Tue 29 Dec 2009, 01:40

#11 Post by npierce »

After failing with "Connection closed by foreign host", what output, if any, do you get from these two commands?:

Code: Select all

grep 127.0.0.1 /etc/hosts
diff /initrd/pup_ro2/etc/hosts.allow /etc/hosts.allow

npierce
Posts: 858
Joined: Tue 29 Dec 2009, 01:40

#12 Post by npierce »

[EDIT, 13:54 UTC]
Before editing /etc/hosts, save the output from these commands for a clue as to what went wrong:

Code: Select all

ls -l /etc/hosts
ls -lc /etc/hosts
[/EDIT]

The error message that you found in /var/log/messages indicates that you probably don't have an entry for 127.0.0.1 in your /etc/hosts file. If the grep 127.0.0.1 /etc/hosts command suggested in my previous post doesn't give you any output, that would verify that it is missing. If so, add a line like this to the file:

Code: Select all

127.0.0.1 localhost puppypc
But replace "puppypc" with the output from this command if different:

Code: Select all

hostname

Saladin
Posts: 94
Joined: Sun 28 Aug 2011, 03:19

#13 Post by Saladin »

npierce wrote:After failing with "Connection closed by foreign host", what output, if any, do you get from these two commands?:

Code: Select all

grep 127.0.0.1 /etc/hosts
diff /initrd/pup_ro2/etc/hosts.allow /etc/hosts.allow
No output from either. They just immediately give me new prompts.
npierce wrote:[EDIT, 13:54 UTC]
Before editing /etc/hosts, save the output from these commands for a clue as to what went wrong:

Code: Select all

ls -l /etc/hosts
ls -lc /etc/hosts
[/EDIT]

The error message that you found in /var/log/messages indicates that you probably don't have an entry for 127.0.0.1 in your /etc/hosts file. If the grep 127.0.0.1 /etc/hosts command suggested in my previous post doesn't give you any output, that would verify that it is missing. If so, add a line like this to the file:

Code: Select all

127.0.0.1 localhost puppypc
But replace "puppypc" with the output from this command if different:

Code: Select all

hostname
Actually, I think I can tell you what went wrong myself. I was following a guide to get some network option to work with Wine a few months ago, and I changed that file several times. I must have been doing things wrong, because I never did get it to work.

Seeing that it was directly my fault is a big relief. It means that if I don't go messing with things, this might not go wrong for me again.

And fixing that file does fix telnet on this computer. But that's just the error message on this computer. The other computer reports nothing for "grep telnetd /var/log/messages | tail", and the "127.0.0.1 localhost puppypc" is already in /etc/hosts, yet it's still giving me the same "foreign host" error.

Edit: figured out the problem with the other computer: hosts.deny was set to deny all. No idea how that got like that, but I deleted that line, and everything runs fine.

Post Reply