Skip to content

Commit 81688a6

Browse files
Merge pull request #1004 from AndriiBarabash/master
Added SSH Tunnel SOCKS Proxy script command
2 parents 6fd9c62 + 589b449 commit 81688a6

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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

0 commit comments

Comments
 (0)