open***设置使用账号密码登录(4)
1.open***隧道搭建使用(1)2.open***隧道客户端搭建使用(3)
3.open***设置使用账号密码登录(4)
4.open***隧道web管理端搭建使用(5)5.open***隧道手动搭建流程(2)参考:
https://www.iblog.zone/archives/openvpn-%E8%AE%BE%E7%BD%AE%E8%B4%A6%E5%8F%B7%E5%AF%86%E7%A0%81%E7%99%BB%E5%BD%95/
1. 写个脚本(脚本是由官网提供)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | vim /etc/openvpn/checkpsw .sh #!/bin/sh ########################################################### # checkpsw.sh (C) 2004 Mathias Sundman # # This script will authenticate OpenVPN users against # a plain text file. The passfile should simply contain # one row per user with the username first followed by # one or more space(s) or tab(s) and then the password. PASSFILE= "/etc/openvpn/psw-file" LOG_FILE= "/etc/openvpn/openvpn-password.log" TIME_STAMP=` date "+%Y-%m-%d %T" ` ########################################################### if [ ! -r "${PASSFILE}" ]; then echo "${TIME_STAMP}: Could not open password file \"${PASSFILE}\" for reading." >> ${LOG_FILE} exit 1 fi CORRECT_PASSWORD=` awk '!/^;/&&!/^#/&&$1=="' ${username} '"{print $2;exit}' ${PASSFILE}` if [ "${CORRECT_PASSWORD}" = "" ]; then echo "${TIME_STAMP}: User does not exist: username=\"${username}\", password=\"${password}\"." >> ${LOG_FILE} exit 1 fi if [ "${password}" = "${CORRECT_PASSWORD}" ]; then echo "${TIME_STAMP}: Successful authentication: username=\"${username}\"." >> ${LOG_FILE} exit 0 fi echo "${TIME_STAMP}: Incorrect password: username=\"${username}\", password=\"${password}\"." >> ${LOG_FILE} exit 1 |
2.接下来给脚本执行权限
1 | chmod 755 /etc/openvpn/checkpsw .sh |
3.配置用户密码文件
1 2 3 4 5 6 | vim /etc/openvpn/psw-file #前面为用户名,后面为密码。 中间使用空格分开 abclent 123456 abc 123456 test test123 |
4.设置服务端配置文件
1 2 3 4 5 6 | vim /etc/openvpn/server .conf #在service.conf最后添加 script-security 3 auth-user-pass-verify /etc/openvpn/checkpsw .sh via- env #指定用户认证脚本 username-as-common-name verify-client-cert none |
5. 设置客户端文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #主要是注释crt和key路径,以及添加一行auth-user-pass client dev tun proto tcp remote xxx.xxx.xxx.xxx 1194 resolv-retry infinite nobind persist-key persist-tun ca ca.crt ;cert cyh.crt #注释 ;key cyh.key #注释 tls-auth ta.key 1 cipher AES-256-CBC comp-lzo verb 3 auth-user-pass #使用用户名密码登录 |
6.重启即可
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义