Skip to content

Installation

James Wragg edited this page Feb 28, 2026 · 2 revisions

Download

Download BeforeConnect.applescript from the latest release or clone the repository:

git clone https://github.com/SkyCMD-Labs/viscosity-otp.git

Place the Script

Put BeforeConnect.applescript somewhere permanent.

~/Library/Application Scripts/com.sparklabs.Viscosity/BeforeConnect.applescript

Or anywhere you prefer — Viscosity accepts any path.

Note

The same script file works for all VPN connections. You only need one copy.

Add to Viscosity

For each VPN connection that uses OTP:

  1. Open ViscosityPreferences
  2. Select the connection and click Edit
  3. Go to the Advanced tab
  4. Under Before Connect Script, click Select… and choose BeforeConnect.applescript
  5. Click Save

Repeat for any additional connections. Each connection can use a different OTP provider — the script reads the command from your configuration automatically.

Verify

After Configuration, test by connecting to your VPN. If everything is set up correctly, the OTP will be submitted automatically and you'll connect without any manual entry.

If something goes wrong, an error dialog will appear with details. See Troubleshooting for common issues.

Updating

To update, simply replace BeforeConnect.applescript with the new version. After replacing the file:

  1. Open Viscosity Preferences
  2. For each connection, clear the Before Connect Script and re-select the updated file
  3. Save

Important: Viscosity caches Before Connect scripts. You must clear and re-add the script after updating, or Viscosity will continue running the old version.

Clone this wiki locally