xxxxxxxxxx
$ keytool -genkey -alias "jwt-sign-key" -keyalg RSA -keystore jwt-keystore.jks -keysize 4096
Enter keystore password:
Re-enter new password:
What is your first and last name?
[Unknown]: Modern API Development
What is the name of your organizational unit?
[Unknown]: Org Unit
What is the name of your organization?
[Unknown]: Packt
What is the name of your City or Locality?
[Unknown]: City
What is the name of your State or Province?
[Unknown]: State
What is the two-letter country code for this unit?
[Unknown]: IN
Is CN=Modern API Development, OU=Org Unit, O=Packt, L=City, ST=State, C=IN correct?
[no]: yes
Generating 4,096 bit RSA key pair and self-signed certificate (SHA384withRSA) with a validity of 90 days
for: CN=Modern API Development, OU=Org Unit, O=Packt,
xxxxxxxxxx
# will extract the public key and print that out
openssl rsa -in mykey.pem -pubout > mykey.pub
# To get a usable public key for SSH purposes
ssh-keygen -y -f key.pem > key.pub
xxxxxxxxxx
chmod 400 ~/.ssh/id_rsa
ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub
xxxxxxxxxx
ssh-keygen -t rsa -P "" -b 4096 -m PEM -f jwtRS256.key
ssh-keygen -e -m PEM -f jwtRS256.key > jwtRS256.key.pub
xxxxxxxxxx
# the directory where the keys are to be stored
# in this case we are using the current file directory
path = Path(__file__).absolute().parent
# initialize the encrypter
encryption = Encryption(path, name=('public_key.pem', 'private1.pem'))
# generates both private and public keys
encryption.generate_keys()
xxxxxxxxxx
#!/usr/bin/env bash
SSH_KEY_FILE=${1}
[ -z $SSH_KEY_FILE ] && echo "Missing required parameter SSH_KEY_FILE." && exit 1
ssh-keygen -f ${SSH_KEY_FILE:?} -y > ${SSH_KEY_FILE:?}.pub