open**用户密码认证登陆

一、基于上一篇文章的密钥认证登陆,现在实现用户密码登陆(在上一篇的基础上修改即可)。

1、首先修改vi /etc/open**/server.conf配置文件,在这里注释五行密钥认证文件,添加以下四行用户密码认证文件:

1)auth-user-pass-verify /etc/open**/auth_pass.sh via-file 允许运行密码认证脚本 2)client-cert-not-required 不需要客户端证书认证 3)username-as-common-name 使用用户名密码登录认证 4)script-security 3 脚本安全性3

2、新建用户密码认证脚本 vi /etc/open**/auth_pass.sh

#!/bin/bash #the username+password is stored in a temporary file #pointed to by $1 username=head -1 $1 password=tail -1 $1 if grep "$username:$password" pass_file > /dev/null 2>&1 then exit 0 else if grep "$username" pass_file > /dev/null 2>&1 then echo "auth-user-pass-verify: Wrong password entered for user '$username'" else echo "auth-user-pass-verify: Unknown user '$username'" fi exit 1 fi

3、创建用户名密码文件 vi /etc/open**/pass_file

wangfeiyu:123(前边用户名,后边密码) ming:123

4、增加auth_pass.sh和pass_file文件权限

chmod 777 /etc/open**/auth_pass.sh chmod 777 /etc/open**/pass_file

5、重启open服务 systemctl restart open@server.service

6、修改客户端配置文件打 C:\ProgramFiles\Open**\config\client.o**

添加一行:auth-user-pass 注释五行: 1)#cert client.crt 2)#key client.key 3);user nobody 4);group nobody 5)#cipher AES-256-CBC

7、重新连接(输入用户名密码点击ok就可以了)

注:如果没有问题的话右下角的图标会变绿,鼠标放在上边能看见tun地址。