Skip to content

Instantly share code, notes, and snippets.

@ygotthilf
Last active November 24, 2023 20:16
Star You must be signed in to star a gist
Embed
What would you like to do?
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@mtwsec
Copy link

mtwsec commented Jun 13, 2023

Thanks! Nice and easy!

@ziyaDev
Copy link

ziyaDev commented Jun 22, 2023

Awesome, thank youuu

@Gokhan-Uysal
Copy link

many thanks

@Aaron2963
Copy link

save my day, thanks

@NNHungLong
Copy link

Thanks

@AColocho
Copy link

Now, it doesn't work because newer version of ssh-keygen no longer uses PEM format as default key format. It have changed to RFC4716 for default key format. Thus, I have to set PEM format explicitly :

ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key

This will work 👍

In case anyone is getting an error from openssl, try this.

@solairerove
Copy link

many thanks

@iamanikeev
Copy link

thank you good sir!

@muhammadfazeel1
Copy link

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment