File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Raycast Script Command
4+ #
5+ # Required parameters:
6+ # @raycast.schemaVersion 1
7+ # @raycast.title Toggle SSH SOCKS Tunnel
8+ # @raycast.mode silent
9+ #
10+ # Optional parameters:
11+ # @raycast.icon 🔒
12+ # @raycast.packageName Developer Utilities
13+ #
14+ # Documentation:
15+ # @raycast.description Toggles an SSH SOCKS proxy tunnel on and off.
16+ # @raycast.author Andrii Barabash
17+ # @raycast.authorURL https://github.com/AndriiBarabash
18+
19+ # --- Configuration ---
20+ # Replace these with your own values
21+ SSH_USER=" <your_user>"
22+ SSH_HOST=" <your_host>"
23+ SSH_PORT=" <your_port>"
24+ INTERFACE=" <your_network_interface>" # e.g., "Wi-Fi" or "Ethernet"
25+ PROXY_PORT=" <your_proxy_port>" # e.g., 1080
26+ # --- End Configuration ---
27+
28+ if pgrep -f " ssh -D $PROXY_PORT " > /dev/null; then
29+ echo " SSH SOCKS tunnel is running. Turning it off..."
30+
31+ # Kill the SSH process
32+ pkill -f " ssh -D $PROXY_PORT "
33+
34+ # Disable the SOCKS proxy
35+ networksetup -setsocksfirewallproxystate " $INTERFACE " off
36+
37+ echo " Tunnel and proxy disabled."
38+ else
39+ echo " SSH SOCKS tunnel is not running. Turning it on..."
40+
41+ # Start the SSH tunnel
42+ ssh -D " $PROXY_PORT " -f -C -q -N -p " $SSH_PORT " " $SSH_USER " @" $SSH_HOST "
43+
44+ # Enable the SOCKS proxy
45+ networksetup -setsocksfirewallproxy " $INTERFACE " 127.0.0.1 " $PROXY_PORT "
46+ networksetup -setsocksfirewallproxystate " $INTERFACE " on
47+
48+ echo " Tunnel and proxy enabled."
49+ fi
You can’t perform that action at this time.
0 commit comments