Get a Pentest and security assessment of your IT network.

Cyber Security

Check SSH Modulus Parameters

TL;DR

You can check if pregenerated SSH modulus parameters are safe by verifying their size and using tools like ssh-keygen -l to confirm they match expected values. Always prefer moduli generated by your system rather than relying on untrusted sources.

Checking SSH Modulus Parameters

  1. Understand the Basics: SSH keys rely on mathematical problems being difficult to solve. The ‘modulus’ is a core part of this, and its size determines the key’s strength. Larger moduli are harder to crack but slower to use.
  2. Check Modulus Size: A minimum modulus size of 2048 bits is recommended for RSA keys. For ECDSA, 256 bits or higher is typical. You can check this using the following command:
    ssh-keygen -l -f /path/to/your/id_rsa

    Replace /path/to/your/id_rsa with the actual path to your private key file.

  3. Verify Key Type and Length: The output of the command above will show you the key type (e.g., RSA, ECDSA) and its length in bits. Ensure this matches what you expect.
    ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD... user@host

    This example shows an RSA key with a length determined by the number of digits after ‘AAAAB3NzaC1yc2E’.

  4. Compare to Known Good Keys (Optional): If you have access to known-good SSH keys generated on a trusted system, compare their modulus values. They should be different (keys are unique!), but similar in length and structure.
    ssh-keygen -l -f /path/to/trusted_id_rsa
  5. Beware of Pre-Generated Keys: Using pre-generated SSH keys from untrusted sources is risky. They could be compromised or intentionally weak. It’s always best to generate your own keys.
    1. Generate a New Key: Use the ssh-keygen command to create a new key pair:
      ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa

      This creates an RSA key with a modulus size of 4096 bits. Adjust the `-t` (key type) and `-b` (bits) options as needed.

    2. Consider ECDSA: For better performance, consider using ECDSA keys:
      ssh-keygen -t ecdsa -f ~/.ssh/id_ecdsa
  6. Check Permissions: Ensure your private key file has restricted permissions (usually 600):
    chmod 600 ~/.ssh/id_rsa

    This prevents other users from reading your private key.

  7. Use a Strong Passphrase: Always protect your private key with a strong passphrase. This adds an extra layer of security.

Further Security Considerations

  • Regular Key Rotation: Change your SSH keys periodically to limit the impact of potential compromises.
  • cyber security Best Practices: Keep your system up-to-date with the latest security patches.
Related posts
Cyber Security

Zip Codes & PII: Are They Personal Data?

Cyber Security

Zero-Day Vulnerabilities: User Defence Guide

Cyber Security

Zero Knowledge Voting with Trusted Server

Cyber Security

ZeroNet: 51% Attack Risks & Mitigation