Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions make-auth-key/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Make an auth key from an OAuth client

Set the variables at the top of the script to your environment.

This will take an OAuth client ID and Secret, and output a new auth key in a JSON object via a pair of API calls.
33 changes: 33 additions & 0 deletions make-auth-key/makeauthkey.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

tailnet="tsjustworks.net"
#read oauth client from files
oauthsecret=$(<$HOME/keys/${tailnet}.oauth.secret)
oauthid=$(<$HOME/keys/${tailnet}.oauth.id)
#tag needs to be supported by the oauth client
tag="tag:nothing"

#generate api key from oauth client
apikey=$(curl -sd "client_id=$oauthid" -d "client_secret=$oauthsecret" \
"https://api.tailscale.com/api/v2/oauth/token" |jq -j '.access_token' )

#generate auth key with api key
authkey=$(curl -su $apikey: "https://api.tailscale.com/api/v2/tailnet/$tailnet/keys" \
--data-binary '
{
"capabilities": {
"devices": {
"create": {
"reusable": false,
"ephemeral": false,
"preauthorized": false,
"tags": [ "'$tag'" ]
}
}
},
"expirySeconds": 86400,
"description": "test"
}'
)

echo $authkey |jq