Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. SQL Server
  3. Question
SQL Server

Is allowing root login in SSH with "PermitRootLogin without-password" a secure method while setting up IP.

Asked by Camellia Kleiber Oct 11, 2021 7.8K views 2 answers
Share

About this question

I have set my live IP in /etc/hosts.allow, and have denied all other hosts. I have also set PermitRootLogin without-password in /etc/ssh/sshd_config.

Do you think its a secure method? Can an cyber attacker crack my key and login to my server? If yes, then how is it possible? 

Your answer

2 Answers

Ranjana Admin JanBask Expert Latest answer

Answered on Jul 10, 2024

Allowing root login via SSH with "PermitRootLogin without-password" can be considered more secure than permitting password-based root logins, but it is not without risks. This setting allows root login only with SSH keys, which can enhance security compared to using passwords. However, there are still some best practices and potential security considerations to keep in mind:

Explanation of "PermitRootLogin without-password"

"without-password": This option allows root login only with SSH keys. Password-based authentication for the root user is disabled, which helps prevent brute-force attacks on root passwords.

Security Advantages

Stronger Authentication: SSH keys are generally considered more secure than passwords because they are harder to brute-force and are not susceptible to common password attacks.

No Password Transmission: Since passwords are not used, there is no risk of them being intercepted during transmission.

Ease of Management: SSH keys can be centrally managed, allowing for easier control over who can access the root account.

Potential Risks and Considerations

Compromised Keys: If an SSH key is compromised, it can be used to gain root access. Therefore, protecting your private keys and using passphrases is crucial.

Physical Security: Ensure the machines from which you connect are secure. If an attacker gains access to your local machine, they could potentially use your SSH key to access the server.

Audit and Monitoring: Monitor and log root access attempts to detect any unauthorized access attempts.

Disable Root Login: For an added layer of security, consider disabling root login altogether and using sudo for administrative tasks. This way, even if a user’s SSH key is compromised, the attacker still needs to escalate privileges to perform administrative tasks.

Best Practices

Use Strong SSH Keys: Ensure you use a strong key type (e.g., RSA 4096-bit or ECDSA 256-bit) and protect private keys with a passphrase.

Limit IP Access: Restrict SSH access to the server to a specific IP range or use a VPN.

Enable Two-Factor Authentication (2FA): Implement 2FA for an added layer of security.

Regular Key Rotation: Periodically rotate SSH keys to limit the risk of key compromise.

Disable Root Login: If possible, disable root login and use a non-root user with sudo for administrative tasks:

  PermitRootLogin no

Firewall Configuration: Ensure your firewall is configured to allow SSH access only from trusted IP addresses.

Configuration Example

To allow root login with SSH keys only, you need to set the following in your /etc/ssh/sshd_config file:

  PermitRootLogin without-password

After making changes to the SSH configuration file, restart the SSH service:

  sudo systemctl restart sshd

Conclusion

While "PermitRootLogin without-password" enhances security compared to allowing password-based root logins, it’s important to implement additional security measures. Using SSH keys, restricting access, monitoring, and considering the complete disabling of root logins in favor of sudo are all practices that can help protect your system.

Was this helpful?

More SQL Server discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest SQL Server Blogs

Guides, tips and career advice on SQL Server from JanBask experts.