PPTP VPN 限制一个账号只允许一个用户来登录
创建auth-up文件
- vi /etc/ppp/auth-up
- chmod a+x /etc/ppp/auth-up

auth-up脚本内容如下
- #!/bin/sh
- # get the username/ppp line number from the parameters
- REALDEVICE=$1
- USER=$2
- # create the directory to keep pid files per user
- mkdir -p /var/run/pptpd-users
- # if there is a session already for this user, terminate the old one
- if [ -f /var/run/pptpd-users/$USER ]; then
- kill -HUP `cat /var/run/pptpd-users/$USER`
- rm /var/run/pptpd-users/$USER
- fi
- # copy the pid file of current user to /var/run/pptpd-users
- cp "/var/run/$REALDEVICE.pid" /var/run/pptpd-users/$USER
流程如下:
1.用户登录判断是否有/var/run/pptpd-users/用户名的文件
2.如果有平滑重启这个vpn用户进程,如果没有创建这个文件,文本里面有用户进程ID
3.老的连接被踢掉,新的连接可以使用
备注:这种模式下,一个账号只允许一个用户使用。
重启pptpd
- service pptpd restart
下边是原文
链接地址:http://poptop.sourceforge.net/dox/skwok/poptop_ads_howto_12.htm#oneconnection
By default, a user can make multiple connections to the pptpd server. To restrict one connection per user, create two script files in the /etc/ppp directory. When the same user logs in twice, the first connection will be disconnected. This is actually done on the ppp level, not with the pptpd.
The first file is /etc/ppp/auth-up
- #!/bin/sh
- # get the username/ppp line number from the parameters
- PPPLINE=$1
- USER=$2
- # create the directory to keep pid files per user
- mkdir -p /var/run/pptpd-users
- # if there is a session already for this user, terminate the old one
- if [ -f /var/run/pptpd-users/$USER ]; then
- kill -HUP `cat /var/run/pptpd-users/$USER`
- rm /var/run/pptpd-users/$USER
- fi
- # write down the username in the ppp line file
- echo $USER > /var/run/pptpd-users/$PPPLINE.new
The second file is /etc/ppp/ip-up.local
- #!/bin/sh
- REALDEVICE=$1
- # Get the username from the ppp line record file
- USER=`cat /var/run/pptpd-users/$REALDEVICE.new`
- # Copy the ppp line pid
- cp "/var/run/$REALDEVICE.pid" /var/run/pptpd-users/$USER
- # remove the ppp line record file
- rm "/var/run/pptpd-users/$REALDEVICE.new"
The method presented here may not be the best one, but it works for me. (If you have a better way, please let me know.)
PPTP VPN 限制一个账号只允许一个用户来登录的更多相关文章
- Java中一个方法只被一个线程调用一次
1.想在运行时抛出异常,终止方法的运行 private final Set<Long> THREADS = new HashSet<>(); public void someM ...
- dedecms--二次开发文章内容页未登录禁止访问和同一个帐号只允许一个ip登录
最近在用dedecms二次开发会员功能,领导要求,会员未登录不允许访问文章内容页,和同一个账号只允许一个ip登录,我是将这两个在一起判断的,判断session存不存在,不存在的情况下就是未登录,这时候 ...
- ftp 一个账号多个家目录的解决方案
通常,配置ftp时,一个ftp账号只对应一个家目录,不能有多个家目录的情况. 但是,根据公司开发项目的需求,需要做到一个ftp对应多个开发目录.有想过创建软链接的,可是发现通过ftp是访问不了的. 举 ...
- vc++高级班之窗口篇[4]---让程序只运行一个实例
大家都看过或者使用过类似只运行一个实例的程序,比如:QQ游戏.部分浏览器 等等! 让一个程序只运行一个实例的方法有多种,但是原理都类似,也就是在程序创建后,有窗口的程序在窗口创建前, 检查系统中是 ...
- 转载 - Vultr VPS注册开通且一键快速安装PPTP VPN和电脑连接使用
本文转载来自:https://www.vultrclub.com/139.html 从2014年Vultr VPS进入市场之后,作为有背景.实力的搅局者,是的最近两年VPS.服务器的用户成本降低.配置 ...
- 从米家到 HomeKit,你只需要一个树莓派
转载:从米家到 HomeKit,你只需要一个树莓派 2017.10.21 该教程针对 Raspbian Stretch (8 月起基于新版 Debian 的系统)更新,请注意文章中提示 Stretch ...
- win7系统的右键菜单只显示一个白色框不显示菜单项 解决办法
如上图所示,桌面或其他大部分地方点击右键菜单,都只显示一个白色框,鼠标移上去才有菜单项看,并且效果很丑 解决办法: 计算机-右键-属性-高级-性能-设置-视觉效果-淡入淡出或滑动菜单到视图,将其前面的 ...
- Android 只开启一个Activity实例
在一个Activity中,多次调用startActivity()来启动另一个Activity,要想只生成一个Activity实例,方法有两种. 方法一:设置起动模式 一个Activity有四种启动模式 ...
- form表单里如果只存在一个文本框,enter键提交
在这里说一说浏览器里form表单的默认行为 我们都知道浏览器是存在很多默认行为的,可能是出于常用行为考虑又或者是历史原因.但有时候我们不需要这些默认行为.以下: 1).当form表单里只存在一个inp ...
随机推荐
- C#中属性与字段的用法
//People.cs public class People { //字段 private string _name; //属性 作用:保护字段,对字段的取值和赋值进行限定,限制非法字段的摄入 pu ...
- 根据 MySQL 状态优化 ---- 4. 临时表
查看 MySQL 服务器运行的各种状态值: mysql> show global status: 4. 临时表 查看设置: mysql> show variables where Vari ...
- Mybatis 批量更新 ORA-00911: 无效字符的错误
使用<foreach></foreach> 批量insert时报错 ORA-00911: 无效字符的错误 <foreach collection="list&q ...
- 【HOW】如何通过URL给Reporting Services报表传递参数
[本地模式Reporting Services] 参见官方文档:http://msdn.microsoft.com/en-us/library/ms154042.aspx 示例:http://serv ...
- su with hyphen and without - su带横杠和不带横杠
The difference between "-" and "no hyphen" is that the latter keeps your existin ...
- winform窗体之间通过 windows API SendMessage函数传值
-----------------------------------------------------------‘接收窗体’代码.cs------------------------------ ...
- java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space 原因:内存溢出,内存一直申请一直占用,无法回收 解决方法:定时重启下服务,
- 11,SFDC 管理员篇 - 报表和数据的可视化
1,Report Builder 1,每一个report type 都有一个 primay object 和多个相关的object 2,Primary object with related obje ...
- MyBatis学习总结(八)——Mybatis3.x与Spring4.x整合(转载)
孤傲苍狼 只为成功找方法,不为失败找借口! MyBatis学习总结(八)--Mybatis3.x与Spring4.x整合 一.搭建开发环境 1.1.使用Maven创建Web项目 执行如下命令: m ...
- javascript arguments解释,实现可变长参数。
在C#中,有可变长参数params[],但是在js中,如何实现这种可变参数呢? 一.可变长参数 arguments是非常好的解决方法,一直不知道javascript有这个东西. 先来看看应用场景,使用 ...