stunnel-client
#!/bin/bash
# giving user passwordless sudo privileges
USER=`whoami`
MYPATH=$(cat /etc/passwd|grep $USER|awk -F: '{print $6}')
# need to be run as root
if [[ "$EUID" -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
#parse args
while getopts "c:i:p:I:P:z:h" arg
do
case $arg in
c) CONFIG=$OPTARG
if [[ ! -f "$CONFIG" ]]; then
echo " unvalid arg for -c, ple make sure the config file is exist "
exit 1
fi
;;
i) PROXY_IP=${OPTARG:-127.0.0.1} ;;
p) PROXY_PORT=${OPTARG:-8888} ;;
I) SERVER_IP=$OPTARG ;;
P) SERVER_PORT=$OPTARG ;;
z) ZTE_PROXY=${OPTARG:-proxysh.zte.com.cn} ;;
h)
echo " -------------args for setting up stunnel--------------------"
echo " -c: client certification"
echo " -i: proxy ip, default to localhost
echo " -p: proxy port, default to 8888"
echo " -I: server ip
echo " -P: server port listened in server"
echo " -z: zte proxy, need to be consistent with system network set"
echo "-------------------------------------------------------------"
exit 0
;;
?) echo "unvalid arg"
exit 1
;;
esac
done
if [[ ! $CONFIG || ! $SERVER_IP || ! $SERVER_PORT ]]; then
echo " need args, ple use -h for help..."
exit 1
fi
HTTP_PROXY=http://$PROXY_IP:$PROXY_PORT
NO_PROXY=localhost,127.0.0.1,10.*.*.*/8
# use internal apt-source
INTER_APT_SOURCE=10.62.99.232
function use_internal_apt_source {
sudo mv /etc/apt/sources.list /etc/apt/sources.list.bk
sudo cat <<EOF >/etc/apt/sources.list
deb http://$INTER_APT_SOURCE/common/ubuntu trusty main restricted multiverse universe
deb http://$INTER_APT_SOURCE/common/ubuntu trusty-security main restricted multiverse universe
deb http://$INTER_APT_SOURCE/common/ubuntu trusty-updates main restricted multiverse universe
deb http://$INTER_APT_SOURCE/common/ubuntu trusty-proposed main restricted multiverse universe
deb http://$inter_apt_source/common/ubuntu trusty-backports main restricted multiverse universe
EOF
sudo apt-get update
}
# if use internal apt-source to install stunnel,
# after install stunnel successfully, ple change back original apt-source
function change_back_apt_source {
sudo mv /etc/apt/sources.list.bk /etc/apt/sources.list
}
# (optional) if can not connect to wwww, user internal apt-source
use_internal_apt_source
sudo apt-get install -y stunnel
# (optional) no matter if stunnel package is installed, change back to origin apt-source
change_back_apt_source
sudo cat << EOF > /etc/stunnel/client.conf
chroot = /var/lib/stunnel4/
setuid = stunnel4
setgid = stunnel4
pid = /stunnel4-client.pid
client = yes
cert = /etc/stunnel/client.pem
sslVersion = SSLv3
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
[squid]
accept = $PROXY_PORT
protocol = connect
protocolHost = $SERVER_IP:$SERVER_PORT
connect = $ZTE_PROXY:80
EOF
sudo cp $CONFIG /etc/stunnel/client.pem
sudo sed -i -r "s/ENABLED=0/ENABLED=1/g" /etc/default/stunnel4
# restart stunnel
sudo service stunnel4 restart
#config proxy: append to $MYPATH/.profile
cat <<EOF >> /$MYPATH/.profile
export http_proxy=$HTTP_PROXY
export https_proxy=$HTTP_PROXY
export no_proxy=$NO_PROXY
EOF
sudo cat <<EOF > /etc/apt/apt.conf
Acquire::http::proxy \"$HTTP_PROXY/\";
Acquire::https::proxy \"$HTTP_PROXY/\";
EOF
source $MYPATH/.profile
sudo apt-get update
stunnel-client的更多相关文章
- Stunnel使用2
1.首先测试一下stunnel.exe,是否能正常运行,正常的话,不会报错,在桌面右下角位置显示. 2.第一步完成后,打开stunnel.conf,对stunnel进行配置,需要修改一下几项:(mys ...
- squid+stunnel+用户密码认证的三种玩法
没办法,应用越来越深入,就会越来越多要求. squid+stunnel+用户密码认证的场景至少以下三个,我会遇到. 1,标准玩法 在服务器上建一个SQUID,加密码认证,然后,其它人通过它上网.(不要 ...
- AWS + Stunnel + Squid ***
[需求] 第一,能***. 第二,在企业网络要能突破端口限制. [原理] 利用AWS提供的一年免费EC2服务,搭建一台自己的VPS,在VPS中利用Stunnel与本机建立加密连接,将本地http请求通 ...
- stunnel-server
#!/bin/bash # need to be run as root ]]; then echo "must to be run as root" exit fi # givi ...
- 【原】基于64位Centos6.2的mcrouter使用简介
此文转载必须注明原文地址,请尊重作者的劳动成果! http://www.cnblogs.com/lyongerr/p/5040071.html 目录 文档控制... 2 1 mcrouter简介.. ...
- 用ccproxy + stunnel做个加密代理
https://www.stunnel.org/downloads.html ccproxy + stunnel做个加密http代理和socks5代理 目前国内用户无法访问某些国外网站,如http:/ ...
- stunnel+CCProxy,搭建加密代理
总所周知,不可抗拒的特别有用心的原因,我们无法访问youtube,picasa,Twitter……国外优秀网站,很多人采用了代理服务器的方法访问. 如果您有一台放在海外的服务器,这个就好办了.下载一个 ...
- Windows系统Stunnel客户端的配置
Stunnel官方就有Windows版本,到下面的地址下载: https://www.stunnel.org/downloads.html 选择”stunnel-X.XX-installer.exe“ ...
- Stunnel使用
建立加密隧道 使用 Stunnel 建立加密隧道 附件中的 Server 和 Clinet 都是已经配置好了的,只需修改 Server 的 stunnel.conf 的 connect 为实际的ip ...
随机推荐
- MySQL主主复制
MySQL5. 主主复制 环境如下: CentOS6.4_64 MySQL5. master1:192.168.10.11 master2:192.168.10.12 1.1 配置 master1 a ...
- C# MVC 自定义ActionResult实现EXCEL下载
前言 在WEB中,经常要使用到将数据转换成EXCEL,并进行下载.这里整理资料并封装了一个自定义ActionResult类,便于使用.如果文章对你有帮助,请点个赞. 话不多少,这里转换EXCEL使用的 ...
- VBA唏嘘戏——简单单元格的设定(实例)
由于有很多个Word文件,所以应用宏会更加方便排版,而且版式较为统一. Sub 设置列宽() ' ' 设置列宽宏 ' ' ActiveDocument.Tables().Cell(, ).Width ...
- 关于springMVC3.0基于注解方式的项目搭建
前言:开发了几个月的AS3项目,感觉JAVA都用不太熟练了.刚好这几个抽的空,就把自己以前用过的Spring框架再搭一边, 并完整的记录下来 开发环境:tomcat + mysql+ java 1.所 ...
- The connection to adb is down, and a severe error has occured.问题解决方法小结
遇到了几次这个问题:The connection to adb is down, and a severe error has occured. You must restart adb and Ec ...
- powershell玩转SQL SERVER所有版本
微软发布了最新的powershell for sql server 2016命令行客户端库.文章介绍了与之相关的实用方法. powershell 传教士 原创文章 2016-06-05, 2016-1 ...
- React之Composition Vs inheritance 组合Vs继承
React的组合 composition: props有个特殊属性,children,组件可以通过props.children拿到所有包含在内的子元素, 当组件内有子元素时,组件属性上的child ...
- VMware下利用ubuntu13.04建立嵌入式开发环境之四
二.telnet.SSH服务器安装与配置 1.telnet 1.1 安装服务器:apt-get install xinetd telnetd 1.2 安装openbsd-inetd:apt-get i ...
- c语言问卷调查
你对自己的未来有什么规划?做了哪些准备? 找一家公司实习积攒创业基金.努力学习专业知识,从各方面完善自身,参与各项活动如辩论赛,竞赛等锻炼自己. 2.你认为什么是学习?学习有什么用?现在学习动力如何? ...
- js⑦
立即执行函数or自执行函数 为了避免全局变量的产生.(function(){ //var a = 10; //var b = 20;//console.log(a,b); -------------v ...