Skip to content

Instantly share code, notes, and snippets.

@ygotthilf
Last active November 7, 2024 10:42
Show Gist options
  • Save ygotthilf/baa58da5c3dd1f69fae9 to your computer and use it in GitHub Desktop.
Save ygotthilf/baa58da5c3dd1f69fae9 to your computer and use it in GitHub Desktop.
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
@jdboris
Copy link

jdboris commented Feb 16, 2023

Thanks

@tgirotto
Copy link

tgirotto commented Mar 7, 2023

thanks

@itaow
Copy link

itaow commented Mar 9, 2023

Thanks!

@Jehovanie
Copy link

I think this link resolve also this problem.
https://symfony.com/bundles/LexikJWTAuthenticationBundle/current/index.html
thank you.

@francesco-plt
Copy link

Thanks! What if I need to use the private key associated to a Metamask wallet to sign? Can I do it by manipulating the key or do I need another type of key altogether?

@meltingrock
Copy link

Thanks

@nikelborm
Copy link

nikelborm commented Apr 22, 2023

Thanks!
BTW @ygotthilf you can add -N '' to ssh keygen and it will not even ask for passphrase

@xiaoyuze88
Copy link

awesome!!! Thx

@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 :)

@honne23
Copy link

honne23 commented Jan 31, 2024

nice

@mthienpont
Copy link

oh hell yeah

@farzadafi
Copy link

concise and useful :)

@peterDitrih
Copy link

thx

@IHsuanLu
Copy link

thanks!

@bmewj
Copy link

bmewj commented Mar 24, 2024

Thanks

@danwonghk01
Copy link

Thanks!! Amazing!

@vlack-coder
Copy link

let me contribute to the thanks
Thanks

@DoobyDouglas
Copy link

awesome

@Rock070
Copy link

Rock070 commented Aug 18, 2024

Thanks!

@jamerlan
Copy link

It was useful for me too! Thanks!

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