转载

mac系统如何设置socks代理

If you're somewhere that has a network that is partly blocked, but allows SSH, or if you are in a coffee shop or something similar and are worried about security, you can setup a SOCKS proxy to route all your traffic via a remote server that you control, and then out onto the Internet.

Setup SOCKS proxy

First, you need to SSH to the remote machine with some special parameters:

ssh -vND 8888 user@host.com

Some detail on those options:

-v verbose mode; useful for debugging -N don't start an interactive shell on the remote server -D setup the SOCKS proxy on port 8888 on localhost

直接上我自己用的脚本:

#!/bin/bash  while [ '' == '' ] do     ssh_d_process_num=`ps aux|grep -E 'ssh /-' |grep -v grep |wc -l`     if [ $ssh_d_process_num == 0 ]; then         sshpass -p "ssh密码" ssh -vND 8080 sshuser@server &     fi      sleep 60 done

实现每分钟检测一次,如果中断,自动重连。

关于如何安装 sshpass 命令,点击传送门: https://gist.github.com/arunoda/7790979

原文  http://blog.41ms.com/post/60.html
正文到此结束
Loading...