Best location to keep SSL certificates and private keys on Ubuntu servers?

Better Stack Team
Updated on November 9, 2023

On Ubuntu servers, the best practice for storing SSL certificates and private keys is to place them in a directory with restricted access. The standard directory for these files is typically within the /etc/ directory, commonly within /etc/ssl/.

Here are recommended locations for SSL certificates and keys on Ubuntu:

  1. SSL Certificates: The SSL certificates, including the public key and any intermediate certificates, are usually stored in a directory such as /etc/ssl/certs/.
  2. Private Keys: The private keys associated with the SSL certificates are stored in a directory such as /etc/ssl/private/.

The permissions for these directories should be set to restrict access, typically allowing only the root user or a specific system user (if necessary) to read or modify the contents. This helps to maintain security and prevent unauthorized access to these sensitive files.

Example of setting the permissions for the directories:

 
sudo chmod 700 /etc/ssl/private
sudo chmod 700 /etc/ssl/certs

It's also important to set permissions for the individual certificate and private key files to ensure restricted access:

 
sudo chmod 600 /etc/ssl/certs/your_certificate.crt
sudo chmod 600 /etc/ssl/private/your_private_key.key

Replace your_certificate.crt and your_private_key.key with the actual names of your certificate and key files.

Remember to keep regular backups of your SSL certificates and private keys in a secure location to prevent data loss in case of accidental deletion or server failure. Additionally, be cautious about file permissions and access rights to maintain security and prevent unauthorized access to these sensitive files.

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

community@betterstack.com

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github