Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save shangmin1990/63f745be3bbcccecb472 to your computer and use it in GitHub Desktop.
Save shangmin1990/63f745be3bbcccecb472 to your computer and use it in GitHub Desktop.
server 初始化配置 及 VPN的搭建
server 初始化配置 及 VPN的搭建
先给ubuntu用户设置密码
sudo passwd ubuntu
更改ssh 允许用户名密码登录
sudo vi /etc/ssh/sshd_config
PasswordAuthentication 改成 yes
重启ssh 服务
sudo service ssh restart
//中文支持
sudo locale-gen zh_CN.UTF-8
//修改时区
sudo dpkg-reconfigure tzdata
//同步时间
sudo ntpdate cn.pool.ntp.org
cn.pool.ntp.org是位于中国的公共NTP服务器
vpn 搭建
sudo apt-get install pptpd
修改配置文件
sudo vi /etc/pptpd.conf
localip 与 remoteip 两行是注释掉的,把注释去掉
值不需要修改,保留默认就好
sudo vi /etc/ppp/pptpd-options
去掉 ms-dns两行的注释
并改为 谷歌的dns 服务器
ms-dns 8.8.8.8
ms-dns 8.8.4.4
sudo vi /etc/ppp/chap-secrets
添加 username pptpd password *
username 与 password 自己补上,pptpd 和 * 不要动,注意空格
sudo service pptpd restart
sudo vi /etc/systcl.conf
把net.ipv4.ip_forward=1的注释去掉
执行 sudo sysctl -p
允许转发
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
关于创建客户端。
linux
vnp connections --- configuare VPN --- ADD
创建一个point - to -point xxxxxxxxxxxx
填写用户名 密码 domain
点击Advance 里有个设置一定要勾上 use point-to-point encryption (MPPE)
现在客户端应该能连上, 如果连不上 考虑aws的安全设置(端口没有开放)和pptpd服务没有启动。
常用命令
查看当前连接的用户
who
显示
ubuntu pts/3 2014-07-02 13:21 (182.18.32.162)
ubuntu pts/4 2014-07-03 14:12 (182.18.32.162)
查看哪个是我
who am i
显示
ubuntu pts/4 2014-07-03 14:12 (182.18.32.162)
强制让一个链接断线
sudo pkill -kill -t pts/3 (别把当前执行命令的用户踢掉了)
查看vpn 链接
ifconfig
显示
ppp0 Link encap:Point-to-Point Protocol
inet addr:172.31.7.175 P-t-P:192.168.0.234 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1496 Metric:1
RX packets:350532 errors:0 dropped:0 overruns:0 frame:0
TX packets:940371 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:20969371 (20.9 MB) TX bytes:1339732194 (1.3 GB)
ppp1 Link encap:Point-to-Point Protocol
inet addr:172.31.7.175 P-t-P:192.168.0.235 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1496 Metric:1
RX packets:34177 errors:0 dropped:0 overruns:0 frame:0
TX packets:43057 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:9985243 (9.9 MB) TX bytes:24495073 (24.4 MB)
两个链接 or
ps -ef|grep pptpd
显示
root 18219 31606 1 13:51 ? 00:00:44 pptpd [182.18.32.162:0A00 - 0B80]
root 18220 18219 0 13:51 pts/0 00:00:00 /usr/sbin/pppd local file /etc/ppp/pptpd-options 115200 172.31.7.175:192.168.0.234 ipparam 182.18.32.162 plugin /usr/lib/pptpd/pptpd-logwtmp.so pptpd-original-ip 182.18.32.162 remotenumber 182.18.32.162
root 18274 31606 0 14:06 ? 00:00:10 pptpd [182.18.32.162:0500 - 0C00]
root 18275 18274 0 14:07 pts/2 00:00:00 /usr/sbin/pppd local file /etc/ppp/pptpd-options 115200 172.31.7.175:192.168.0.235 ipparam 182.18.32.162 plugin /usr/lib/pptpd/pptpd-logwtmp.so pptpd-original-ip 182.18.32.162 remotenumber 182.18.32.162
ubuntu 18895 18378 0 14:45 pts/4 00:00:00 grep --color=auto pptpd
root 31606 1 0 7月01 ? 00:00:00 /usr/sbin/pptpd
两个链接 234 和 235 强制断开链接 把当前链接的进程关掉就好了
sudo kill -9 pid (exp 182754 就会关掉 235的链接)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment