Display days till Tailscale key expiration.
Display key expiration date on this specific device.
$ tailscale status --json --self | jq --raw-output .Self.KeyExpiry
2023-07-15T22:54:13Z
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
#!/bin/bash # 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" else echo "key expired" fi
Get days till key expiration.
$ get_days_till_expiration.sh
165 days till key expitation
See key expiry guide.