Mac下自动开启SSH 隧道

SSH遇到网络抖动,就会断开,影响翻墙梯的连接,找到了autossh这个神器,可以断线重连

0x0 安装autossh

brew install autossh

0x01 设置mac开机启动配置文件~/Library/LaunchAgents/homebrew.mxcl.autossh.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>homebrew.mxcl.autossh</string>
    <key>ProgramArguments</key>
    <array>
    <string>/usr/local/bin/autossh</string>
    <string>-M</string>
    <string>8111</string>
    <string>-N</string>
    <string>shuhai@8.8.8.8</string>
    <string>-p</string>
    <string>22</string>
    <string>-D</string>
    <string>localhost:8032</string>
    <string>-C</string>
    <string>-i</string>
    <string>/Users/shuhai/.ssh/id_rsa</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
  </dict>
</plist>

0x02

launchctl load   ~/Library/LaunchAgents/homebrew.mxcl.autossh.plist
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.autossh.plist

0x03
在翻墙工具中增加sockets5端口,如 SwitchyOmega 中配置为 SOCKETS5, 127.0.0.1, 8032