Can't SSH into Linux server
I have access to a Ubuntu Server (10.4) that I can't SSH into. From a terminal the connection times out and from putty the connection is refused.
I have checked that sshd is running and listening on all interfaces, iptables has all chains empty and default is ACCEPT, additional firewall is accepting on port 22 inbound, and all outbound. I can't telnet into port 22 either.
What could the problem be and how can I troubleshoot it?
Solution 1:
Try logging in to the console then:
ssh localhost
That will test the ssh daemon on the host without regard to the firewall or other filtering.
Solution 2:
Are you running the server or is someone else? Do you have root access on the server? It sounds like you may be blocked on the server end. Not much you can do from the client side. First thing is to try using the '-v', '-vv', or '-vvv' options to get some debug info about what's going on:
ssh -vv server.name.org
If that's unhelpful you can do a traceroute, ping, nmap on the host to try and see if you can see the machine on the network:
traceroute server.name.org
ping server.name.org
nmap -v -A server.name.org
It's likely you're being blocked by the firewall on server.name.org and not fixable on the client side.
Do you have access to server? If so, you can eliminate the firewall as a potential problem on the server by disabling it, trying to ssh, and then re-enabling it (all from the server):
sudo servce iptables stop; ssh -v localhost; sudo service iptables start
Are you sure the sshd process is running? Try looking to see if it's running:
sudo service sshd status
If it's not running you need to start it:
sudo service sshd start
You can enable it permanently with:
sudo chkconfig sshd on
Solution 3:
Don't know if this is too late, but I fixed this issue in Linux Lite by opening the port on the firewall (UFW).
sudo ufw allow 22 #replace 22 with whatever port
source: https://www.linuxliteos.com/forums/network/sshd-or-openssh/msg19245/#msg19245
Solution 4:
I had the same issue where the server was responsive to ping and the logon prompt, but would not accept connections.
Looking at all the related sshd
config files I noticed that it was missing the /etc/pam.d/sshd
config file.
Since I had VM console access I used scp
through the console to copy this config file from another server which resolved the issue.
The command for copying the file from a remote server is:
scp -r root@remoteserver:/etc/pam.d/sshd /etc/pam.d/
Restart the ssh
service using this command:
service sshd restart
You should now be able to log on.