海运的博客

Openwrt下使用Stunnel加密Squid取代SSH转发

发布时间:September 3, 2012 // 分类:Squid,OpenWrt // No Comments

Stunnel真是个好东西,可以使用SSL加密任意两点间的TCP连接,本文记录使用Stunnel加密Squid代理服务器来代替SSH数据转发
服务器端配置Squid正向代理:

#https://www.haiyun.me
http_port 127.0.0.1:8080
icp_port 0
visible_hostname proxy.www.haiyun.me
cache_mgr  admin@www.haiyun.me
cache_effective_user squid
cache_effective_group  squid 
via off     
forwarded_for off
acl localnet src 127.0.0.0/24
http_access allow localnet

生成OpenSSL证书:

openssl req -new -x509 -days 365 -nodes -out stunnel.pem -keyout stunnel.pem
chmod 400 stunnel.pem

服务器端Stunnel安装配置:

yum install stunnel
compression=zlib
syslog=no
debug=7
output=/var/log/stunnel.log
setuid=nobody
setgid=nobody
pid=/var/run/stunnel.pid
cert=/etc/stunnel/stunnel.pem
key=/etc/stunnel/stunnel.pem
client=no
[squid]
accept=8000
connect=127.0.0.1:8080

Openwrt下安装配置Stunnel客户端:

opkg update
opkg install stunnel
compression=zlib
syslog=no
debug=7
output=/var/log/stunnel.log
pid=/var/run/stunnel.pid
client=yes
[squid]
accept=8080
connect=www.haiyun.me:8000

客户端服务器端启动Stunnel:

stunnel

此时客户端和Squid代理服务器之间的数据是使用SSL加密的,其它HTTP代理服务器也同样适用此方法,如Kingate代理服务器

Openwrt路由下打开Modem猫web管理界面

发布时间:September 2, 2012 // 分类:OpenWrt // No Comments

Openwrt网段:192.168.1.1/24
Modem网段: 192.168.0.1/24
Openwrt下配置和Modem相连接端口IP:

#https://www.haiyun.me
ifconfig eth1.1 192.168.0.2 netmask 255.255.255.0

Iptables配置SNAT:

iptables -t nat -A POSTROUTING -d 192.168.0.1 -j MASQUERADE

iptables放行:

iptables -A INPUT -i eth1.1 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth1.1 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT

tracert测试:

C:\Users\Administrator>tracert 192.168.0.1

通过最多 30 个跃点跟踪到 192.168.0.1 的路由

  1     1 ms     1 ms     1 ms  OpenWrt.lan [192.168.1.1]
  2  1006 ms  2723 ms     2 ms  192.168.0.1

跟踪完成。

Centos6编译安装kingate错误解决

发布时间:September 2, 2012 // 分类:Linux服务 // No Comments

之前有介绍在Centos5下安装kingate代理服务器,在Centos6下同样安装kingate在编译时遇到以下错误:

#https://www.haiyun.me
make[2]: *** [KDnsCache.o] Error 1
make[2]: Leaving directory `/root/workspace/proxy/kingate-2.1/src'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/root/workspace/proxy/kingate-2.1/src'
make: *** [all-recursive] Error 1
make[2]: *** [mysocket.o] Error 1
make[2]: Leaving directory `/root/workspace/proxy/kingate-2.1/src'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/root/workspace/proxy/kingate-2.1/src'
make: *** [all-recursive] Error 1

编辑src/KDnsCache.cpp文件,头部添加:

#include <string.h>

编辑src/mysocket.cpp头部添加

#include <malloc.h>

Puppet错误Run of Puppet configuration client already in progress; skipping解决

发布时间:August 31, 2012 // 分类:Puppet // No Comments

Puppet在同步时遇到以下错误:

notice: Run of Puppet configuration client already in progress; skipping

删除puppetdlock重试解决:

rm /var/lib/puppet/state/puppetdlock

Centos服务器安全配置SSH使用Google Authenticator二次验证

发布时间:August 30, 2012 // 分类:网络安全 // 2 Comments

CentOS安装所需组件:

yum -y install mercurial pam-devel

安装Google Authenticator:

#https://www.haiyun.me
wget --no-check-certificate https://google-authenticator.googlecode.com/files/libpam-google-authenticator-1.0-source.tar.bz2
tar jxvf libpam-google-authenticator-1.0-source.tar.bz2 
cd libpam-google-authenticator-1.0
make
make install

SSH登录时调用google-authenticator模块,编辑:

/etc/pam.d/sshd

第一行添加:

auth       required     pam_google_authenticator.so

修改SSH配置文件:

vim /etc/ssh/sshd_config

添加或修改以下内容:

ChallengeResponseAuthentication yes
UsePAM yes

重启SSH:

/etc/init.d/sshd restart

生成google-authenticator配置,运行:

google-authenticator 
Do you want authentication tokens to be time-based (y/n) y
https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/root@node1.www.haiyun.me%3Fsecret%3DABEXG5K6CVB56BXY
#此网址为生成的二维码,客户端扫描
Your new secret key is: www.haiyun.me
Your verification code is 582849
Your emergency scratch codes are:
  30776626
  14200155
  80795568
  23936997
  21919909
#上面几行数字为应急码
Do you want me to update your "/root/.google_authenticator" file (y/n) y
#更新配置文件
Do you want to disallow multiple uses of the same authentication
token? This restricts you to one login about every 30s, but it increases
your chances to notice or even prevent man-in-the-middle attacks (y/n) y
#禁止一个口令多用
By default, tokens are good for 30 seconds and in order to compensate for
possible time-skew between the client and the server, we allow an extra
token before and after the current time. If you experience problems with poor
time synchronization, you can increase the window from its default
size of 1:30min to about 4min. Do you want to do so (y/n) n
#客户端与服务器时间误差
If the computer that you are logging into isn't hardened against brute-force
login attempts, you can enable rate-limiting for the authentication module.
By default, this limits attackers to no more than 3 login attempts every 30s.
Do you want to enable rate-limiting (y/n) y
#次数限制

Android安装google-authenticator客户端,扫描添加上方网址的二维码,以后在登录服务器时输入账号密码的同时还需输入google-authenticator即时生成的验证码才能登录。

ssh www.haiyun.me
Verification code: 
Password: 
分类
最新文章
最近回复
  • opnfense: 谢谢博主!!!解决问题了!!!我之前一直以为内置的odhcp6就是唯一管理ipv6的方式
  • liyk: 这个方法获取的IPv6大概20分钟之后就会失效,默认路由先消失,然后Global IPV6再消失
  • 海运: 不好意思,没有。
  • zongboa: 您好,請問一下有immortalwrt設定guest Wi-Fi的GUI教學嗎?感謝您。
  • 海运: 恩山有很多。
  • swsend: 大佬可以分享一下固件吗,谢谢。
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
  • 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
  • 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
  • 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...
归档