Generate a Self-signed SSL in Linux

This article will go over generating a self-signed SSL in Linux. If you need a certificate authority issued SSL, please see our SSL page or you can contact us for more information.

  1. Log into the server via SSH as the root user. If you are unfamiliar with SSL, please see How do I establish an SSH connection to my server?
  2. Once logged in as the root user, run the following command which specifies the encryption level (in this case 2048 bits):
  3. openssl genrsa -out domain.key 2048

  4. Once that command is run, run the following command to generate the certificate signing request (CSR) and certificate key:

  5. openssl req -new -nodes -key domain.key -out domain.csr

  6. The above command will prompt you for the SSL information as listed below:

  7. Country Name (2 letter code) [GB]:
     State or Province Name (full name) []:.
     Locality Name (eg, city) [Newbury]:
     Organization Name (eg, company) [My Company Ltd]:
     Organizational Unit Name (eg, section) []:
     Common Name (eg, your name or your server's hostname) []:
     Email Address []:

  8. The next information is optional but can be entered if you choose:

  9. A challenge password []:
    An optional company name []: 

  10. The common name portion of the form above is the important part. This will be your domain name, such as www.domain.com or domain.com. Note: these two domains are different when it comes to SSLs even if they both point to the same location. In generating a self-signed SSL, it doesn't matter as much as a CA issued SSL though.
  11. Create a self-signed certificate from the certificate-signing request (.csr file):
  12. openssl x509 -req -days 3650 -in domain.csr -signkey domain.key -out domain.crt

  13. Remove the domain.csr file as it is no longer needed.
  14. Place the .crt and .key files into Apache's SSL directory and configure Apache to use those files for the self-signed SSL.