Install jwt-cli on Ubuntu 24.04

Install jwt-cli on Ubuntu 24.04

The jwt-cli is a command line tool used to create, decode, verify, and inspect JSON Web Tokens (JWTs). It's especially useful for developers working with JWT-based authentication systems who want to quickly manipulate tokens without needing to write scripts or use online tools. This tutorial explains how to install jwt-cli on Ubuntu 24.04.

Install jwt-cli

Download tar.gz file from releases page:

wget -qO jwt.tar.gz https://github.com/mike-engel/jwt-cli/releases/latest/download/jwt-linux.tar.gz

Extract executable from archive to /usr/local/bin directory:

sudo tar xf jwt.tar.gz -C /usr/local/bin jwt

We can check the jwt-cli version using the following command:

jwt --version

Remove unneeded file:

rm -rf jwt.tar.gz

Testing jwt-cli

To use jwt-cli, we can encode a JSON payload into a JWT and then decode it to inspect its contents.

For example, the command creates a JWT and saves the result to a file:

jwt encode --secret=pwd123 '{"name":"John"}' > jwt.txt

Then, the following command reads the JWT from the file and decodes it, displaying the header and payload in a readable format:

jwt decode - < jwt.txt

Output:

Token header
------------
{
  "typ": "JWT",
  "alg": "HS256"
}

Token claims
------------
{
  "iat": 1746008028,
  "name": "John"
}

Uninstall jwt-cli

To uninstall jwt-cli, remove the related file:

sudo rm -rf /usr/local/bin/jwt

Leave a Comment

Cancel reply

Your email address will not be published.