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 ...
随机推荐
- eclipse NoClassDefFoundError错误
问题描述:eclipse中执行一个java web项目,代码中依赖都是正常的,发布到tomcat中调试就提示NoClassDefFoundError错误, 问题分析:首先确定工程中该类确实存在,因为代 ...
- 使用delphi+intraweb进行微信开发1--微信平台接入
示例代码已经放出!请移步使用delphi+intraweb进行微信开发1~4代码示例进行下载,虽为示例代码但是是从我项目中移出来的,封装很完备适于自行扩展和修改. iw14.0.50来了,在新的版本中 ...
- Create a geoprocessing tool to buffer a layer and retrieve messages____sync
using System.Drawing; using System.Text; using System.Windows.Forms; using System.Runtime.InteropSer ...
- eclipse 引用项目(转)
1. 项目右键 -->Properties 2. Java Build Path a) Projects --> Add b) Required Project Selection - ...
- 安装Office 2010后出现正在配置
OFFICE 2010 MSDN版出来后,下载安装 ,启动后发现每次打开都会出现“正在配置”的进度,删除重装亦不成功,对SETUP.EXE改名也不行,最后找到这个方法,成功,备忘: 运行以下内容: r ...
- instanceof关键字
instanceof是Java.php的一个二元操作符(运算符),和==.>.<是同一类东西.由于它是由字母组成的,所以也是Java的保留关键字.它的作用是判断其左边对象是否为其右边类的实 ...
- String类常用方法
1.String类的特点,字符串一旦被初始化就不会被改变. 2.String对象定义的两种方式 ①String s = "affdf";这种定义方式是在字符串常量池中创建一个Str ...
- JAVASCRIPT 中 FOR (VAR I IN DATA) 循环数组项
今天在改代码的时候发现有很多代码的循环是用 for(var i in data)写的,我通常都是用for(var i=0;i<data.length;i++) 就查看了一下,原来这两个是有区别的 ...
- android开发--下载图片
1.背景介绍 网络上图片的请求,是我们最常见的网络请求之一,不亚于对json/xml数据的请求.一般要展示给用户看的,都不会是纯粹的文字,往往都是图文信息.而在移动互联网时代,图文又往往需要最新的资讯 ...
- svn记录删除
Delete SVN Folders.reg 批量删除文件夹里的SVN 文件 ------------------------------------------------------------- ...