Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I used ssh from another host to this new machine. Encountered the following:
ssh: connect to host 172.20.2.2 port 22: Connection refused
I check the new machine information as the follows:
========================
iptables:
Fire wall is stopped
ps outputs:
root 4002 1 0 09:23 00:00:00 /usr/sbin/sshd
port 22 status:
sshd 4002 root 3u IPv4 12673 TCP *:ssh(LISTEN)
=========================
I also can use ssh to itself.
I can not use scp to copy files from other hosts to the new machine and can not use PUTTY to log on it.
From the strace outputs i only found the following, but i can not find the root cause from it.
=========================
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3
fcntl(3, F_SETFD, FD_CLOEXEC) = 0
connect(3, {sa_family=AF_INET, sin_port=htons(22), sin_addr=inet_addr("172.20.2.2")}, 16) = -1 ECONNREFUSED (Connection refused)
close(3) = 0
write(2, "ssh: connect to host 172.20.2."..., 64ssh: connect to host 172.20.2.2 port 22: Connection refused
) = 64
exit_group(255) = ?
==========================
ssh -vv outputs as follows:
OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to 172.20.2.2 [172.20.2.2] port 22.
debug1: connect to address 172.20.2.2 port 22: Connection refused
ssh: connect to host 172.20.2.2 port 22: Connection refused
Could you check the logs on the server. Sometimes they will say why the connection was refused.
Some things that could cause problems:
Permissions of $HOME/.ssh are too lax
Permissions of $HOME are too lax
UseDNS yes in /etc/ssh/sshd_config, and you don't have a dns entry or entry in /etc/hosts
Entry in /etc/hosts has hostname.domain or hostname listed first, when other is expected. Check for username@hostname in known_hosts entry or authorized_keys entry. It's at the end.
AllowUsers is used in /etc/sshd/sshd_config and you are not listed
>>/etc/hosts.allow and /etc/hosts.deny
I just installed the OS. I didn't enter any information into these files. Thanks
>>i am root authentication
>>/etc/hosts file
Thanks for the information. I already added the hosts information into this file. I can ping outside hosts before, i suspected the hosts file wasn't the root cause, right?
I can ssh to itself, so i suspect my ssh should be installed, does it make sense?
Thanks for all your help. I have resolved the problem.
I found the ip address has a conflict with another host. I change the ip address but the issue persists.
Then i compared with the other hosts which can ssh on, i found i used a wrong gw. After i add the default gw, i can use ssh.
Allowing root logins in ssh is a bad idea. It will be targeted by script kiddies. You can disable root logins in sshd_config. If you need root cron jobs with root access, there is an option that uses key pairs for root logins, even if regular users use password authentication.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.