Skip to content

Instantly share code, notes, and snippets.

@ygotthilf
Last active May 27, 2023 19:51
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
@canhlinh
Copy link

canhlinh commented Dec 7, 2022

Use this command to convert the keys to one line string

awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}'  jwtRS256.key
awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}'  jwtRS256.key.pub

@XDanny322
Copy link

Thank you indeed!

@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

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

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