- Use https://jwt.io/ to decode JWT
- It also shows the various parts. A JWT token has multiple parts in base64, separated by a point character.

- It also shows the various parts. A JWT token has multiple parts in base64, separated by a point character.
Create JWT token
Create PEM SSH key:
openssl genrsa -out private.pem 2048
Create base64 from header and payload:
$ echo -n '{"typ":"JWT","alg":"RS256","kid":"http://10.10.14.17/private.pem"}' | base64 -w0 | sed s/+/-/ | sed -E s/=+$//
=> $header
$ echo -n '{"username":"aaa","email":"a@a.a","admin_cap":1}' | base64 -w0 | sed s/+/-/ | sed -E s/=+$//
=> $payload
Create signature with the created private key:
echo -n "$header.$payload" | openssl dgst -sha256 -binary -sign private.pem | openssl enc -base64 | tr -d '\n=' | tr -- '+/' '-_' => $sig
Now, combine all parts to the JWT token:
$header.$payload.$sig
You can verify this JWT token e.g. via https://jwt.io/.
Leave a Reply
You must be logged in to post a comment.