ssh debug message: Cannot bind any address.

I can’t login to SSH on localhost or from a remote OS.

The connection is refused after multiple attempts at password authentication (but my .ssh/known_hosts file does get a key placed into it on my first unique attempt to connect).

I’ve banged my head against the wall trying to determine what’s wrong, but I am too new at this to be of any use to myself. Based on my research online, I’m including some information I hope will be useful to better informed folk:

This is the result of “sudo /usr/sbin/sshd -d”

debug1: sshd version OpenSSH_5.0p1
debug1: private host key: #0 type 0 RSA1
debug1: read PEM private key done: type RSA
debug1: private host key: #1 type 1 RSA
debug1: read PEM private key done: type DSA
debug1: private host key: #2 type 2 DSA
debug1: rexec_argv[0]=‘/usr/sbin/sshd’
debug1: rexec_argv[1]=‘-d’
debug1: Bind to port 22 on 0.0.0.0.
Bind to port 22 on 0.0.0.0 failed: Address already in use.
Cannot bind any address.

In ssh_config the following lines are uncommented:

Port 22
Protocol 2

And here is an extract of key uncommented lines in sshd_config:

Port 22
ListenAddress 0.0.0.0

Protocol 2

HostKey /etc/ssh/ssh_host_key
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key

Authentication:

RSAAuthentication yes

for nx

PubkeyAuthentication yes
AuthorizedKeysFile authorized_keys2

PasswordAuthentication yes
PermitEmptyPasswords no

ChallengeResponseAuthentication yes

UsePAM yes
X11Forwarding yes

AllowUsers nx
AllowGroups remotessh nx
GatewayPorts yes
X11DisplayOffset 50
AllowTcpForwarding yes
Compression yes
MaxAuthTries 6
PasswordAuthentication yes
PermitRootLogin yes
PrintMotd yes
AllowUsers nx
AllowGroups remotessh nx
GatewayPorts yes
X11DisplayOffset 50
AllowTcpForwarding yes
Compression yes
MaxAuthTries 6
PermitRootLogin yes
PrintMotd yes

In response to “ps ax | grep [s]shd” I get

3271 ? Ss 0:00 /usr/sbin/sshd -o PidFile=/var/run/sshd.init.pid

And in response to “netstat -ln | grep 22” I get

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN

And finally in response to “/sbin/ifconfig” I get

eth0 Link encap:Ethernet HWaddr 00:1E:C2:0A:86:8A
inet addr:192.168.1.10 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::21e:c2ff:fe0a:868a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8622 errors:0 dropped:0 overruns:0 frame:0
TX packets:4955 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2382117 (2.2 Mb) TX bytes:901929 (880.7 Kb)
Interrupt:17

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1086 errors:0 dropped:0 overruns:0 frame:0
TX packets:1086 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:196851 (192.2 Kb) TX bytes:196851 (192.2 Kb)

I am too new at this to see the problem if one is revealed by these diagnostics. I hope someone can help with this.

I also have vncserver running on this system. Could this be the reason I get

Bind to port 22 on 0.0.0.0 failed: Address already in use.
Cannot bind any address.

in response to “sudo /usr/sbin/sshd -d” ?

fogelfish wrote:

> I am too new at this to see the problem if one is revealed by these
> diagnostics. I hope someone can help with this.

What’s actually listening on port 22, then? Try ‘netstat -planet |
grep :22’


Menes Narmer
menesofmemphis [at] gmail [dot] com

“Unity and humility is the lesson all of history teaches.”

That’s the wrong way to start a service anyway. If you wanted to debug sshd you should add -d to SSHD_OPTS in /etc/sysconfig/ssh and start it the normal way with /etc/init.d/ssh start

>> AllowUsers nx
>> AllowGroups remotessh nx
>> GatewayPorts yes
>> X11DisplayOffset 50
>> AllowTcpForwarding yes
>> Compression yes
>> MaxAuthTries 6
>> PasswordAuthentication yes
>> PermitRootLogin yes
>> PrintMotd yes
>> AllowUsers nx
>> AllowGroups remotessh nx
>> GatewayPorts yes
>> X11DisplayOffset 50
>> AllowTcpForwarding yes
>> Compression yes
>> MaxAuthTries 6
>> PermitRootLogin yes
>> PrintMotd yes

You’ve played with FreeNX haven’t you? {Grin}

The lines ‘AllowUsers’ and ‘AllowGroups’ are pretty mean… they say that
unless you are the USER nx, AND you exist in either the ‘remotessh’ or ‘nx’
group, then you cannot log in.

Remove both of those lines and you should be fine

Your posting (as above) lists things twice… are they that way in your
sshd_config file? Make sure things are duplicated, as the last one always
takes precedence and it can be confusing if you change the first one you
find and it doesn’t work.

sshd is running properly already, as evidenced by the ‘port 22 already in
use’ you obtained and the

> And in response to “netstat -ln | grep 22” I get
> tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN

output from netstat.

Remember to restart sshd after you remove the icky “AllowUsers/AllowGroups”
lines (both sets!)

su - root -c rcsshd restart

(root password when prompted)

Hope this helps

Loni


L R Nix
lornix@lornix.com

Oh pooh! make sure things AREN’T duplicated in sshd_config file.

Sorry,

Loni

L R Nix
lornix@lornix.com

Thank you for all the good advice. I did comment out AllowUsers and AllowGroups in sshd_config. (The duplication of lines was not in the config file; it was my mistake in the forum post.)

So then I restarted ssh. At first I tried to use “su - root -c rcsshd restart” but I was reprimanded by the system:

Usage: /usr/sbin/rcsshd {start|stop|status|try-restart|restart|force-reload|reload|probe}

So I then entered “su - root” and “rcsshd restart” separately. Then the result of “netstat -planet | grep :22” was

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
0 309021 25389/sshd

And finally the result of “ssh localhost”:

The authenticity of host ‘localhost (127.0.0.1)’ can’t be established.
RSA key fingerprint is 54:17:75:01:2e:85:78:56:86:f6:d1:4e:1c:c7:50:ea.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘localhost’ (RSA) to the list of known hosts.
Password:
Password:
Password:
brian@localhost’s password:
Last login: Thu Aug 7 12:19:29 2008 from 192.168.1.10
Have a lot of fun…

I thought everything was fine, but after a few seconds, this:

hostname: Host name lookup failure

and I was returned to my user prompt.

This is better but something is still wrong. What does the “Host name lookup failure” mean?

BTW, one reason I started working on this in the first place was because of FreeNX. When I got to the point of configuring nxserver, the process stopped when it was unable to connect to 127.0.0.1. I don’t have my original notes, so I can’t be specific here, but in any case I will open a new thread I try and fail at that again.

And one other aside: the reason I tried FreeNX was because my remote desktop using vncserver was so darn slow! That’s a separate post as well.

su - root -c rcsshd restart

The reason this failed is because -c takes a single argument. You have to quote multiple words.

su - root -c 'rcsshd restart'

fogelfish wrote:

>> The authenticity of host ‘localhost (127.0.0.1)’ can’t be established.
>> RSA key fingerprint is
>> 54:17:75:01:2e:85:78:56:86:f6:d1:4e:1c:c7:50:ea.
>> Are you sure you want to continue connecting (yes/no)? yes
>> Warning: Permanently added ‘localhost’ (RSA) to the list of known
>> hosts.
>> Password:
>> Password:
>> Password:
>> brian@localhost’s password:
>> Last login: Thu Aug 7 12:19:29 2008 from 192.168.1.10
>> Have a lot of fun…
> I thought everything was fine, but after a few seconds, this:
>> hostname: Host name lookup failure
> and I was returned to my user prompt.
>
> This is better but something is still wrong. What does the “Host name
> lookup failure” mean?

If I remember correctly, FreeNX may have added some things to
~/.ssh/known_hosts or changed your ~/.bashrc file.

Considering you didn’t receive a prompt, something is running before it
finishes the login process (which would then give you your prompt). Likely
places to look are .bashrc, .profile, .bash_profile

To make things simpler, you could copy the original versions of those files
from /etc/skel, which is used to populate new accounts when their home
directories are created.

(all this is done as ‘brian’, from your posting)

cp /etc/skel/.bashrc .
cp /etc/skel/.profile .

I am curious why it queried ‘Password:’ three times before asking
for ‘brian@localhost’s password:’ Strange.

You might try that again with ‘ssh -v localhost’ to obtain more output
(verbose)

Is ‘brian’ your current user account or a test accout? It might be easier
to delete ‘brian’ and recreate it, or create another account.

Please check ~/.ssh/config and ~/.ssh/known_hosts.

If you haven’t configured .ssh/config or .ssh/known_hosts yourself, you may
want to delete those two files and try to ssh again. They may be
contributing to the inability to login.

Loni

L R Nix
lornix@lornix.com

Loni,

I copied the files from /etc/skel and looked into known_hosts. The only entry there was for localhost.

Here is the result of entering “ssh -v localhost”:

brian@dhcppc254:~> ssh -v localhost
OpenSSH_5.0p1, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: Connection established.
debug1: identity file /home/brian/.ssh/id_rsa type -1
debug1: identity file /home/brian/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.0
debug1: match: OpenSSH_5.0 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.0
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host ‘localhost’ is known and matches the RSA host key.
debug1: Found key in /home/brian/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Trying private key: /home/brian/.ssh/id_rsa
debug1: Trying private key: /home/brian/.ssh/id_dsa
debug1: Next authentication method: keyboard-interactive
Password:
debug1: Authentication succeeded (keyboard-interactive).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Requesting X11 forwarding with authentication spoofing.
debug1: Requesting authentication agent forwarding.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
Last login: Fri Aug 8 14:45:06 2008 from console
Have a lot of fun…
hostname: Host name lookup failure
brian@dhcppc254:~>

Does this information reveal any clues to the “Host name lookup failure”?

fogelfish wrote:

> Does this information reveal any clues to the “Host name lookup
> failure”?

Hmmm… uh… no?

Based on the messages being output, login is proceeding normally, last login
is shown, and then the motd (message of the day) is shown (“Have a lot of
fun…”).

Seems like the shell ssh gives you is not normal.

Possibly remnants of FreeNX.

Please can you post the output of

ls -l .ssh

and then the contents of .ssh/config and .ssh/known_hosts

Thanks.


L R Nix
lornix@lornix.com

L R Nix wrote:

To be honest, the issues involved are strange. Would it be possible to log
in as root, and use yast to delete this user account (and also remove all
files) and then recreate it anew?

Could solve all the problems in one operation, resetting everything to
defaults.

Just a thought…

Loni

L R Nix
lornix@lornix.com

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Or, before you do that, just create and test with a new user.

Good luck.

L R Nix wrote:
| L R Nix wrote:
|
| To be honest, the issues involved are strange. Would it be possible
to log
| in as root, and use yast to delete this user account (and also remove all
| files) and then recreate it anew?
|
| Could solve all the problems in one operation, resetting everything to
| defaults.
|
| Just a thought…
|
| Loni
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFInT8H3s42bA80+9kRAnEWAJ9I829oJghcASs/MZOG6EMi5a8mzACfUUbX
7RIxoC+0Q6tYzpDN1HY8/Ts=
=8Lsn
-----END PGP SIGNATURE-----

Loni, I’d like to run two ideas past you. First of all, I already have another user in which I previously made no changes to the default configuration. When I “ssh localhost” in that account the same thing happens (with one request for the password rather than three). Bottom line is the same result: “Host name lookup failure”.

I poked around a bit on the net and got the idea of looking at my /etc/hosts file. In that I have commented out the default definition

127.0.0.1 localhost loopback

and in its place I put

127.0.0.1 localhost www.dci.site

because I have a virtual domain called www.dci.site that Apache needs to know about. So maybe the lack of a loopback directive in /etc/hosts is the culprit.

I also gave better notice to my shell prompt:

brian@dhcppc254:~>

Maybe the configuration files inside /etc/sysconfig/network have given my system the hostname “dhcppc254” and this has overridden “localhost” as the default hostname (I do not have a real domain associated with this machine).

I can’t support these theories from real technical knowledge but they are both a circumstantial fit.

I will uncomment the localhost loopback line in /etc/hosts to see if that fixes my problem. On the other hand, I won’t mess with the configuration files in /etc/sysconfig/network until I understand what I should be doing there.

Any comments would be most welcome.

Here’s one other little bit of information someone could make use of:

brian@dhcppc254:~> ps auxw | grep dhcp
root 2200 0.0 0.0 8116 296 ? Ss Aug08 0:00 /sbin/dhcpcd -H -D -K -N -t 999999 -h linux-oj5k -c /etc/sysconfig/network/scripts/dhcpcd-hook eth0
avahi 2632 0.0 0.0 27652 1640 ? Ss Aug08 0:00 avahi-daemon: running [dhcppc254.local]
brian 3159 0.0 0.0 5240 820 pts/11 S+ 23:21 0:00 grep dhcp

fogelfish wrote:

>
> Loni, I’d like to run two ideas past you. First of all, I already have
> another user in which I previously made no changes to the default
> configuration. When I “ssh localhost” in that account the same thing
> happens (with one request for the password rather than three). Bottom
> line is the same result: “Host name lookup failure”.
>
> I poked around a bit on the net and got the idea of looking at my
> /etc/hosts file. In that I have commented out the default definition >
> 127.0.0.1 localhost loopback and in its place I put
>> 127.0.0.1 localhost www.dci.site
> because I have a virtual domain called www.dci.site that Apache needs
> to know about. So maybe the lack of a loopback directive in /etc/hosts
> is the culprit.
>
> I also gave better notice to my shell prompt:
>> brian@dhcppc254:~>
> Maybe the configuration files inside /etc/sysconfig/network have given
> my system the hostname “dhcppc254” and this has overridden “localhost”
> as the default hostname (I do not have a real domain associated with
> this machine).
>
> I can’t support these theories from real technical knowledge but they
> are both a circumstantial fit.
>
> I will uncomment the localhost loopback line in /etc/hosts to see if
> that fixes my problem. On the other hand, I won’t mess with the
> configuration files in /etc/sysconfig/network until I understand what I
> should be doing there.
>
> Any comments would be most welcome.
>
>

Hmmm, yes, replacing the original contents of the 127.0.0.1 line
in /etc/hosts is a good thing.

If you desire an entry for www.dci.site, add another line:

127.0.0.1 www.dci.site www.dci.site

Often you’ll see things like that, but with 127.0.0.2 or so. Actually,
almost ANYTHING which has 127 as the first octet is a ‘localhost’ type
connection.

Your hostname of ‘dhcppc254’ is odd too (as you mentioned in your next
posting). Check the settings in yast/network devices under hostname/dns
settings… verify the ‘change hostname via dhcp’ is cleared.

Loni

L R Nix
lornix@lornix.com

Loni, I turned off “change hostname via dhcp” and I added back the localhost loopback line in /etc/hosts; now I can ssh localhost!

Thanks for sticking with me, giving me advice, and helping me verify ideas.

And I hope this information is useful to the next person who confronts the same problem.

fogelfish wrote:

>
> Loni, I turned off “change hostname via dhcp” and I added back the
> localhost loopback line in /etc/hosts; now I can ssh localhost!
>
> Thanks for sticking with me, giving me advice, and helping me verify
> ideas.
>
> And I hope this information is useful to the next person who confronts
> the same problem.
>
>

Hooray!!! Congratulations!

So very glad you’ve got it working!

And that’s what we at the forums are here for. {Smile}

Enjoy!

Loni

L R Nix
lornix@lornix.com