Skip to content

Configuration

James Wragg edited this page Feb 28, 2026 · 1 revision

Viscosity OTP uses macOS preferences (defaults) to map each VPN connection to a shell command that fetches the OTP code.

Adding a Connection

defaults write net.skycmd.viscosity-otp "<connection-name>" "<otp-command>"
  • <connection-name> — the name of your VPN connection exactly as it appears in Viscosity (case-sensitive)
  • <otp-command> — a shell command that outputs your OTP code to stdout

Example

defaults write net.skycmd.viscosity-otp "My Work VPN" "/usr/local/bin/op item get abc123 --otp"

See Providers for commands for specific OTP tools.

Viewing Configuration

To see all configured connections:

defaults read net.skycmd.viscosity-otp

To see the command for a specific connection:

defaults read net.skycmd.viscosity-otp "<connection-name>"

Removing a Connection

defaults delete net.skycmd.viscosity-otp "<connection-name>"

Removing All Configuration

defaults delete net.skycmd.viscosity-otp

Testing a Command

Before connecting, verify your OTP command works by running it directly:

defaults read net.skycmd.viscosity-otp "<connection-name>" | sh

This should output a 6-digit OTP code. If it doesn't, fix the command before connecting.

Multiple Connections

Each connection has its own command. You can use different providers for different connections:

defaults write net.skycmd.viscosity-otp "Work VPN" "/usr/local/bin/op item get abc123 --otp"
defaults write net.skycmd.viscosity-otp "Client VPN" "/usr/local/bin/bw get totp my-client-vpn"

All connections share the same BeforeConnect.applescript — the script reads the connection name from Viscosity at runtime and looks up the appropriate command.

Where Is the Config Stored?

Configuration is stored in a standard macOS preferences plist:

~/Library/Preferences/net.skycmd.viscosity-otp.plist

You can also edit this file directly with a plist editor, but using defaults is recommended.

Clone this wiki locally