Generate a self signed certificate on Linux

in sysops •  8 years ago  (edited)

Generate a self signed certificate on Linux




Linux


Description:


This article will walk through generating a self signed certificate or certificate signing request (CSR) on a linux server.


Pre-Requisites:


None


Generate the key:



RHEL   RHEL   &   CentOS   CentOS:

openssl genrsa -out "/etc/pki/tls/private/gitlab-registry.key" 4096



Debian   Debian   &   Ubuntu   Ubuntu:

openssl genrsa -out "/etc/ssl/private/gitlab-registry.key" 4096


Generate the certificate:



RHEL   RHEL   &   CentOS   CentOS:

openssl req -x509 -sha512 -nodes -newkey rsa:4096 -days 365 -keyout /etc/pki/tls/private/gitlab.key -out /etc/pki/tls/certs/gitlab.crt



Debian   Debian   &   Ubuntu   Ubuntu:

openssl req -x509 -sha512 -nodes -newkey rsa:4096 -days 365 -keyout /etc/ssl/private/gitlab.key -out /etc/ssl/certs/gitlab.crt


Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:SomeState
Locality Name (eg, city) []:SomeCity
Organization Name (eg, company) [Internet Widgits Pty Ltd]:yourdomain.tld
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:servername.yourdomain.tld
Email Address []:[email protected]


Optionally Generate a CSR:



RHEL   RHEL   &   CentOS   CentOS:

openssl req -new -sha512 -key "/etc/pki/tls/private/gitlab-registry.key" -out "/etc/pki/tls/certs/gitlab-registry.csr"



Debian   Debian   &   Ubuntu   Ubuntu:

openssl req -new -sha512 -key "/etc/ssl/private/gitlab-registry.key" -out "/etc/ssl/certs/gitlab-registry.csr"


Post Requisites:


None


References:


clusterfrak.com

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!