Problem with logging in via SSH after messing with access permissions

Problem

Issuing the following commend caused the system to be unreachable via SSH:

chmod a+rwx / -R

Here the entire filesystem, and all mounted partitions, were modified to be world-writable. One immediate consequence of this is that ssh logins fail:


ssh_exchange_identification: Connection closed by remote host

Looking in /var/log/auth.log upon the host we can see the cause of this failure:

error: Could not load host key: /etc/ssh/ssh_host_rsa_key
error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
error: @ WARNING: UNPROTECTED PRIVATE KEY FILE! @
error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
error: Permissions 0777 for '/etc/ssh/ssh_host_dsa_key' are too open.
error: It is recommended that your private key files are NOT accessible by others.
error: This private key will be ignored.
error: bad permissions: ignore key: /etc/ssh/ssh_host_dsa_key
error: Could not load host key: /etc/ssh/ssh_host_dsa_key
fatal: /var/run/sshd must be owned by root and not group or world-writable.

Solution

These errors are fixable fairly easily unless we are not disallowed to access linux machine otherwise then through SSH:

(none):~# chmod 600 /var/run/sshd
(none):~# chmod 600 /etc/ssh/ssh_host_*

Was this answer helpful?

 Print this Article

Also Read

How to Check VPS Memory/RAM Usage with SSH

There are a few tools built-in to most Linux distros for gauging and fine-tuning your...

Installing OpenVPN

Many ppl found that installing VPN on linux is not that easy, the abvailable installation guides...

How to disable Firewall on RHEL / CentOS / RedHat Linux

How do I turn off or disable firewall permanently under RHEL / Fedora Linux / Red Hat Enterprise...

What are the advantages of a VPS ?

VPS gives you the functions and features and of a managed dedicated server but without the price....

cPanel: Unactive License File

cPanel may spit out a "Unactive License File" error when new IP addresses or added or when your...

Powered by WHMCompleteSolution