Auto Start SSH Tunneling on Mac
Prerequisites
Skip this step if you have it.
Install Homebrew :
|
|
Install SSH-Key using Keygen :
|
|
Add SSH-Key fingerprint into the tunneling :
|
|
Step to auto connect SSH Tunneling
- Install
sshpass
using Homebrew
|
|
- Create file
~/scripts/startup/startup.sh
to connect ssh tunneling automatically, and type code like below.
|
|
-
Type
chmod +x ~/scripts/startup/startup.sh
on your terminal to change the file can be execute. -
Create file
~/Library/LaunchAgents/com.startup.plist
to run startup.sh automatically when the laptop is starting, and type code like below.
|
|
- Create file
~/reload.sh
to handle when disconnected from tunnel and type code like below.
|
|
-
Type
chmod +x ~/reload.sh
on your terminal to change the file can be executed. -
Type
launchctl load -w ~/Library/LaunchAgents/com.startup.plist
to run startup agent. -
Setup your browser with proxy SOCKS port forwarding. If you using Chrome, you can use SOCKS plugin and forward it to tunneling port.
Thankyou
Medium - Adding Startup Scripts to Launch Daemon
SSHPASS - SSHPASS non Interactive SSH Login Shell Script SSH Password