macOS and iOS shortcuts
Tailscale works with the Shortcuts app on macOS and iOS to provide several built-in shortcut actions, allowing you to automate tasks. For example, you could create shortcuts to connect your device to a tailnet, use an exit node, or switch user accounts.
You can combine the Tailscale actions with other available actions to customize tasks, such as automatically connecting to your tailnet if your device is not on your home Wi-Fi.
Depending on how you set up your shortcuts, you access shortcuts in the Shortcuts app, the menu bar, in Spotlight, as well as other places.
Tailscale macOS and iOS shortcuts are supported on Tailscale v1.36 or later, for macOS 12.0 or later and iOS 15.0 or later.
Tailscale provides support for the following actions:
- Connection actions
- Exit Node actions
- Switch Account action
- Get Status action
- Switch accounts example
- Connect to your tailnet example
- Connect Connects your device to your tailnet.
- Disconnect Disconnects your device from a tailnet.
- Use Exit Node Starts using an exit node. You can specify an exit node by node name or by Tailscale IP. If you don’t specify a name or Tailscale IP address, the shortcut user interface will prompt you to choose an exit node.
- Stop Using Exit Node Stops using an exit node.
Using and stop using an exit node are sensitive actions, since an exit node affects all network traffic on your device. On iOS, an exit node action requires that your device is currently unlocked.
You must already have an exit node on your tailnet before you can use it from a macOS or iOS shortcut.
- Switch Account Switches user accounts. If you don’t specify a user name to use when switching accounts, a user interface will prompt you to choose an account.
- Get Status Retrieves Tailscale client status information.
The Get Status action returns values for the following.
- Connected (boolean) Whether the device is connected to a tailnet.
- Account Name (string) The Tailscale user name, for example, firstname.lastname@example.org.
- Using Exit Node (boolean) Whether the device is using an exit node.
- Exit Node Name (string) The name of the exit node.
For general information about creating a macOS shortcut, see Apple’s documentation at Create a custom shortcut on Mac.
In the Shortcuts app, click File and then click New Shortcut.
Click Shortcut Name and provide a name, such as Switch Tailscale user.
In the right-hand panel, click Apps.
Search for or scroll to the Tailscale app and click it.
Drag the Get Status action to the shortcut editor.
In the right-hand panel, search for the If action, and drag the If action to the shortcut editor and place it below the Get status statement. You can also find the If action by clicking Categories, Scripting, and then Control Flow.
For the If statement, click Status and choose the Tailscale Account Name variable.
Click Condition, click Is, and then click Text. Enter a user account, such as email@example.com.
From the right-hand panel, drag the Switch Account action to the shortcut editor, and place it below the If statement but above the Otherwise statement.
For the Switch account to statement, click account name. For the value, use a different user account, such as firstname.lastname@example.org.
From the right-hand panel, drag another Switch Account action to the shortcut editor, and place it below the Otherwise statement but above the End if statement.
Edit this Switch account to statement to use the original user account value, email@example.com.
Test your shortcut by clicking the Run icon at the top of the shortcut editor.
From the Shortcuts app, in the All Shortcuts folder, you can see the shortcut that you created. You can run the shortcut from that folder. You can also add the shortcut to the Menu Bar folder, which makes the shortcut appear in the macOS taskbar.
This example shows how to create an iOS shortcut that automatically connects your device to your tailnet when your devices joins a specific Wi-Fi network. The example uses the Connect action.
In this example, the Wi-Fi network name is PangoLAN.
For general information about creating an iOS shortcut, see Apple’s documentation at Create a custom shortcut on iPhone or iPad.
In the Shortcuts app, choose the Automation tab from the bottom of the screen.
Tap ＋ in the upper-right corner of the screen and choose Create Personal Automation.
From the Wi-Fi category, choose the “PangoLAN” network.
Tap Add Action.
From the Tailscale app group, choose the Connect action.