Skip to content

Instantly share code, notes, and snippets.

@goshki
Last active May 26, 2026 13:01
Show Gist options
  • Select an option

  • Save goshki/dd418ac7d85a58a347cb394b46663c55 to your computer and use it in GitHub Desktop.

Select an option

Save goshki/dd418ac7d85a58a347cb394b46663c55 to your computer and use it in GitHub Desktop.
macOS Universal Clipboard and Handoff reset (requires admin rights)

Script for macOS Continuity, Universal Clipboard, and Handoff reset – installation guide

This guide will help you create a standalone terminal command to reset macOS Continuity, Universal Clipboard, and Handoff. Once installed, you can trigger this fix from anywhere on your Mac.

Step 1: Download the handoff-reset script file attached to this gist

Step 2: Make the script executable

By default, text files cannot be run as programs. Grant execution permissions by running:

chmod +x handoff-reset

Step 3: [OPTIONAL] Move it to your system PATH

To make the command accessible from anywhere in the terminal, it needs to be placed in a global system directory (/usr/local/bin).

Run this combined command, which ensures the directory exists and then securely moves your file into it (you will be prompted for your Mac administrator password):

sudo mkdir -p /usr/local/bin && sudo mv handoff-reset /usr/local/bin/

Step 4: How to use it

Installation is complete! Whenever Universal Clipboard or Handoff stops working, simply open your Terminal in any location (or – if you skipped step 3 – in the location of handoff-reset script) and type:

handoff-reset

The script will automatically clear the caches, restart the necessary daemons, and output a live log showing if your Mac can "see" your iPad (or other macOS/iOS/tvOS devices).

(Note: Because the log stream runs continuously, press Ctrl + C to stop monitoring and return to your normal terminal prompt once you are finished).

Typical log message confirming other handoff-capable devices have been detected looks like this:

2026-05-26 14:45:00.000000+0200 0x38ecf    Default     0x0                  3015   3    sharingd: (CoreUtils) [com.apple.sharing:SDNearbyAgentCore] Devices of required software version for enhanced discovery; macCount=1, iPadCount=1, iPhoneCount=0, tvCount=0

P.S. It's worth noting that usually corporate security tools like Netskope, Zscaler, and Cisco Secure Client are among the most common reasons Universal Clipboard and Handoff fail, even when the devices can "see" each other.

How Netskope breaks Continuity / Handoff

Handoff and Universal Clipboard rely on a two-step process. Netskope usually ignores the first step, but breaks the second:

1. Discovery (BLE) - Allowed Your Mac and iPad use Bluetooth Low Energy (BLE) to say, "I am nearby." Netskope doesn't monitor Bluetooth, which is why you see the success log (macCount=1, iPadCount=1).

2. Authentication & Transfer (Wi-Fi/iCloud) - Blocked by Netskope Once they see each other, they attempt to verify your Apple ID and securely transfer the clipboard data using Wi-Fi (Apple Wireless Direct Link/AWDL) and iCloud servers. Netskope interferes here in three ways:

  • SSL Inspection (Certificate Pinning): Netskope acts as a "Man-in-the-Middle" to inspect web traffic. However, Apple's background daemons (sharingd, apsd, identityservicesd) use strict "certificate pinning." If Netskope intercepts traffic to *.apple.com or *.icloud.com and replaces Apple's certificate with its own, the Mac will instantly drop the connection for security reasons. The handshake fails.
  • Peer-to-Peer Wi-Fi Blocking: Universal clipboard uses a hidden peer-to-peer Wi-Fi network (AWDL) to transfer the copied text securely. Netskope's network extension often intercepts local network traffic and accidentally drops or misroutes these peer-to-peer packets.
  • Port Blocking: Apple services require constant background connections to the Apple Push Notification service (APNs) over TCP port 5223. If Netskope blocks this port or restricts long-lived background sockets, Continuity stops working.

How to confirm if Netskope is the culprit

1. The Quick Test If your company allows it, temporarily "Disable" or "Pause" the Netskope client in your Mac's menu bar. Wait 30 seconds, and try copying and pasting between devices. If it instantly works, Netskope is the problem.

2. The Log Test Since you are already comfortable with the terminal, you can check if Apple's services are complaining about SSL errors or dropped connections.

Run this command and then try to copy/paste from your iPad to your Mac:

log stream --predicate 'process == "identityservicesd" || process == "apsd"' | grep -i "error\|ssl\|certificate"

If you see errors about "certificate validation failed," "connection reset," or "SSL," Netskope is definitely breaking the connection.

How to fix it

If Netskope is the issue, you likely can't fix it permanently on your own because Netskope policies are controlled by your company's IT department.

You will need to submit an IT ticket asking them to: "Add Apple Continuity and APNs domains to the Netskope SSL Decryption Bypass list."

Specifically, IT needs to bypass SSL inspection and routing for:

  • *.apple.com
  • *.icloud.com
  • *.push.apple.com
  • TCP port 5223

Once they whitelist Apple's background services, Universal Clipboard and Handoff will work seamlessly through Netskope.

#!/bin/bash
echo "🔄 Resetting macOS Universal Clipboard and Handoff..."
echo "1/4 Updating preferences..."
defaults write ~/Library/Preferences/com.apple.coreservices.useractivityd.plist ClipboardSharingEnabled 1
defaults write com.apple.sharingd LegacyHandoffEnabled -bool YES
echo "2/4 Clearing caches..."
rm -rf ~/Library/Caches/com.apple.coreservices.useractivityd
echo "3/4 Reloading LaunchAgents..."
launchctl unload /System/Library/LaunchAgents/com.apple.pboard.plist 2>/dev/null
launchctl load /System/Library/LaunchAgents/com.apple.pboard.plist 2>/dev/null
echo "4/4 Restarting daemons (You may be prompted for your Mac password)..."
sudo killall pboard sharingd useractivityd bluetoothd 2>/dev/null
echo "✅ Reset complete! Daemons are restarting in the background."
echo ""
echo "📡 Starting log stream to monitor sharingd for 'iPad'..."
echo "🛑 Press Ctrl+C to stop the log stream and exit."
echo "--------------------------------------------------------"
# Run the continuous log stream
log stream --level debug --predicate 'process == "sharingd"' | grep -i "iPad"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment