• Generate GPG key using command gpg --full-generate-key with below values:
key type: RSA
key size: 3072
Expiration: none
Real name: <Sonatype username>
Email address: <Sonatype email>
Comment: <blank>
  • Publish public key to a key server
gpg --keyserver keyserver.ubuntu.com --send-keys <key-id>
  • Export secret key ring file with ASCII armor(surrounded by —BEGIN and END—)
gpg --armor --export-secret-keys <key-id> > secret-key-ring-file.gpg
  • Get the secret key ring file value as a one-liner with $ instead of newline character, to add to an environment variable
cat secret-key-ring-file.gpg | sed ':a; $!N; s|\n|$|; ta; P;D' | sed 's/\$/\\n/g'