当前位置:   article > 正文

一键部署open***服务

一键部署open***服务

一键部署超级简单易用的openvpn服务器,支持多证书+多账号[密码]认证

一. 服务器端部署

项目地址:GitHub - guoew/openvpn-install: OpenVPN road warrior installer for Debian, Ubuntu and CentOS

1.1. 下载安装

  1. git clone https://github.com/guoew/openvpn-install.git
  2. cd openvpn-install && bash openvpn-install.sh

然后按步骤操作 

  1. Welcome to this OpenVPN "road warrior" installer!
  2. I need to ask you a few questions before starting the setup.
  3. You can leave the default options and just press enter if you are ok with them.
  4. First, provide the IPv4 address of the network interface you want OpenVPN
  5. listening to.
  6. IP address: 172.28.0.3
  7. This server is behind NAT. What is the public IPv4 address or hostname?
  8. Public IP address / hostname: xxx.xxx.xxx.xxx
  9. Which protocol do you want for OpenVPN connections?
  10. 1) UDP (recommended)
  11. 2) TCP
  12. Protocol [1-2]: 1
  13. What port do you want OpenVPN listening to?
  14. Port: 5556
  15. Which DNS do you want to use with the VPN?
  16. 1) Current system resolvers
  17. 2) 1.1.1.1
  18. 3) Google
  19. 4) OpenDNS
  20. 5) Verisign
  21. DNS [1-5]: 1
  22. Finally, tell me your name for the client certificate.
  23. Please, use one word only, no special characters.
  24. Client name: yangzhou
  25. Okay, that was all I needed. We are ready to set up your OpenVPN server now.
  26. Press any key to continue...
  27. 已加载插件:fastestmirror, langpacks
  28. Repository epel is listed more than once in the configuration
  29. Repository epel is listed more than once in the configuration
  30. Repository epel-debuginfo is listed more than once in the configuration
  31. Repository epel-source is listed more than once in the configuration
  32. Loading mirror speeds from cached hostfile
  33. * centos-sclo-rh: mirror.fra10.de.leaseweb.net
  34. 软件包 epel-release-7-14.noarch 已安装并且是最新版本
  35. 无须任何处理
  36. 已加载插件:fastestmirror, langpacks
  37. Repository epel is listed more than once in the configuration
  38. Repository epel is listed more than once in the configuration
  39. Repository epel-debuginfo is listed more than once in the configuration
  40. Repository epel-source is listed more than once in the configuration
  41. Loading mirror speeds from cached hostfile
  42. * centos-sclo-rh: mirror.fra10.de.leaseweb.net
  43. 软件包 iptables-1.4.21-35.el7.x86_64 已安装并且是最新版本
  44. 软件包 1:openssl-1.0.2k-21.el7_9.x86_64 已安装并且是最新版本
  45. 软件包 ca-certificates-2021.2.50-72.el7_9.noarch 已安装并且是最新版本
  46. 正在解决依赖关系
  47. --> 正在检查事务
  48. ---> 软件包 openvpn.x86_64.0.2.4.11-1.el7 将被 安装
  49. --> 解决依赖关系完成
  50. 依赖关系解决
  51. ================================================================================================================================================================================================================================================================
  52. Package 架构 版本 源 大小
  53. ================================================================================================================================================================================================================================================================
  54. 正在安装:
  55. openvpn x86_64 2.4.11-1.el7 epel 527 k
  56. 事务概要
  57. ================================================================================================================================================================================================================================================================
  58. 安装 1 软件包
  59. 总下载量:527 k
  60. 安装大小:1.2 M
  61. Downloading packages:
  62. openvpn-2.4.11-1.el7.x86_64.rpm | 527 kB 00:00:02
  63. Running transaction check
  64. Running transaction test
  65. Transaction test succeeded
  66. Running transaction
  67. 正在安装 : openvpn-2.4.11-1.el7.x86_64 1/1
  68. 验证中 : openvpn-2.4.11-1.el7.x86_64 1/1
  69. 已安装:
  70. openvpn.x86_64 0:2.4.11-1.el7
  71. 完毕!
  72. init-pki complete; you may now create a CA or requests.
  73. Your newly created PKI dir is: /etc/openvpn/server/easy-rsa/pki
  74. Using SSL: openssl OpenSSL 1.0.2k-fips 26 Jan 2017
  75. Generating RSA private key, 2048 bit long modulus
  76. ..............................+++
  77. ..+++
  78. e is 65537 (0x10001)
  79. Using SSL: openssl OpenSSL 1.0.2k-fips 26 Jan 2017
  80. Generating a 2048 bit RSA private key
  81. ........................................+++
  82. .....................................................................................+++
  83. writing new private key to '/etc/openvpn/server/easy-rsa/pki/easy-rsa-7646.2pG6Rk/tmp.hxnW4c'
  84. -----
  85. Using configuration from /etc/openvpn/server/easy-rsa/pki/easy-rsa-7646.2pG6Rk/tmp.twLmR0
  86. Check that the request matches the signature
  87. Signature ok
  88. The Subject's Distinguished Name is as follows
  89. commonName :ASN.1 12:'server'
  90. Certificate is to be certified until Oct 12 07:29:27 2031 GMT (3650 days)
  91. Write out database with 1 new entries
  92. Data Base Updated
  93. Using SSL: openssl OpenSSL 1.0.2k-fips 26 Jan 2017
  94. Generating a 2048 bit RSA private key
  95. .........................................................................................................+++
  96. .............+++
  97. writing new private key to '/etc/openvpn/server/easy-rsa/pki/easy-rsa-7738.fLRMAQ/tmp.uEwI2e'
  98. -----
  99. Using configuration from /etc/openvpn/server/easy-rsa/pki/easy-rsa-7738.fLRMAQ/tmp.zb5J81
  100. Check that the request matches the signature
  101. Signature ok
  102. The Subject's Distinguished Name is as follows
  103. commonName :ASN.1 12:'yangzhou'
  104. Certificate is to be certified until Oct 12 07:29:27 2031 GMT (3650 days)
  105. Write out database with 1 new entries
  106. Data Base Updated
  107. Using SSL: openssl OpenSSL 1.0.2k-fips 26 Jan 2017
  108. Using configuration from /etc/openvpn/server/easy-rsa/pki/easy-rsa-7805.u82YJj/tmp.GtEwWf
  109. An updated CRL has been created.
  110. CRL file: /etc/openvpn/server/easy-rsa/pki/crl.pem
  111. chown: 无效的用户: "nobody.nogroup"
  112. 23423
  113. success
  114. success
  115. success
  116. success
  117. success
  118. success
  119. Created symlink from /etc/systemd/system/multi-user.target.wants/openvpn-server@server.service to /usr/lib/systemd/system/openvpn-server@.service.
  120. Finished!
  121. Your client configuration is available at: /root/yangzhou.ovpn
  122. If you want to add more clients, you simply need to run this script again!

将客户端配置文件 /root/client.ovpn,下载到本地以备客户端使用

1.2. 添加账号

在openvpn目录下的userfile.sh中添加用户和密码,以空格隔开

  1. cat /etc/openvpn/userfile.sh
  2. username password

 开发云服务器端口 端口有tcp和udp 记得要开对应的

二. 客户端部署使用

2.1. 安装openvpn客户端

  1. 客户端下载地址:https://swupdate.openvpn.org/community/releases/openvpn-install-2.4.0-I602.exe
    安装步骤略(可自定义安装路径)

2.2. 配置客户端

将安装好的客户端打开,点击Import file 把准备好的客户端配置文件导入进去。

2.3. 连接openvpn服务器

打开客户端,点击Connect,使用服务器端已添加的账号登录

END

附:

安装完毕后,再次执行脚本openvpn-install.sh 会有四个菜单选项(添加、撤销、卸载、退出),可根据自身实际情况应用,如下:

  1. Looks like OpenVPN is already installed.
  2. What do you want to do?
  3. 1) Add a new user
  4. 2) Revoke an existing user
  5. 3) Remove OpenVPN
  6. 4) Exit
  7. Select an option [1-4]:

这里有个不足之处是,当使用多证书时,账号是通用的。即同一个账号,可以应用于不同的证书。

如果想要不同用户使用不同的证书进行登录[无账号],欢迎访问原项目地址:
https://github.com/Nyr/openvpn-install

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/202936
推荐阅读
相关标签
  

闽ICP备14008679号