command-line-interfacetailscale

How to list tailscale devices from the cli?


I am trying to ssh between devices in my tailnet - but I do not want to continuously check device names in my tailscale dashboard. Is there any way to list tailnet devices with the tailscale CLI tool?


Solution

  • Does tailscale status address your need?

    If not, you can generate an API key from Keys and then use the API:

    And grab your Organization from General

    BASE_URL="https://api.tailscale.com/api/v2"
    
    TAILNET="" # Replace with Organization
    TOKEN=""   # Replace with API Key
    
    curl \
    --silent \
    --location \
    --get \
    --header "Authorization: Bearer ${TOKEN}" \
    ${BASE_URL}/tailnet/${TAILNET}/devices \
    | jq -r .devices[].name