Display days till Tailscale key expiration.

Display key expiration date on this specific device.

$ tailscale status --json --self | jq --raw-output .Self.KeyExpiry

Create shell script to calculate days till key expiration (using method described earlier to display days till certificate expiration).

$ cat get_days_till_expiration.sh
# calculate days till key expiration

# key expiration
expiration_date="$(tailscale status --json --self | jq --raw-output .Self.KeyExpiry)"
expiration_date_s=$(date -d "${expiration_date}" +%s)

# now
now_date_s=$(date -d "now" +%s)

# calculate difference
date_difference=$(( (expiration_date_s - now_date_s) / 86400 ))

# display date difference
if [ "$date_difference" -ge 0 ]; then
  echo "$date_difference days till key expitation"
  echo "key expired"

Get days till key expiration.

$ get_days_till_expiration.sh
165 days till key expitation

See key expiry guide.