Other Articles

Servers – Ensure SSH Public Host Key Permissions Are Configured

Support > Fixing Checks > Server

26 March, 2026

This check ensures that SSH public host key files have secure permissions and ownership.

Public host keys are used in SSH authentication to verify server identity. Improper permissions can allow unauthorized users to modify these keys, potentially compromising the SSH service.

Check Details

  • Resource: Server
  • Check: Ensure SSH public host key permissions are configured
  • Risk: Incorrect permissions may allow unauthorized modification of SSH public keys, leading to potential compromise of SSH authentication.

Remediation Steps

  1. Open a terminal session on the server with root or sudo privileges.
  2. Run the following command to list SSH public host key files and verify their permissions.

    find /etc/ssh -xdev -type f -name 'ssh_host_*_key.pub' -exec stat {} \;
    
  3. Review the output and ensure that permissions are set to 0644 (readable by all, writable only by root).
  4. If incorrect permissions are found, run the following command to fix them.

    find /etc/ssh -xdev -type f -name 'ssh_host_*_key.pub' -exec chmod 0644 {} \;
    
  5. Ensure that all SSH public host key files are owned by root:root.

    find /etc/ssh -xdev -type f -name 'ssh_host_*_key.pub' -exec chown root:root {} \;
    
  6. Re-run the audit command to confirm that permissions and ownership are correctly configured.
  7. Implement regular security audits to ensure SSH key integrity over time.