一键部署open***服务

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

一. 服务器端部署

项目地址:https://github.com/guoew/openvpn-install

1.1. 下载安装

# git clone https://github.com/guoew/openvpn-install.git
# cd openvpn-install &&  bash openvpn-install.sh
Welcome to this OpenVPN "road warrior" installer!

I need to ask you a few questions before starting the setup.
You can leave the default options and just press enter if you are ok with them.

First, provide the IPv4 address of the network interface you want OpenVPN
listening to.
IP address: 172.27.0.2 #默认获取本机ip,直接回车

This server is behind NAT. What is the public IPv4 address or hostname?
Public IP address / hostname: 18.24.64.250 #输入主机公网ip

Which protocol do you want for OpenVPN connections?
   1) UDP (recommended)
   2) TCP
Protocol [1-2]: 1 #选择连接协议

What port do you want OpenVPN listening to?
Port: 1194 #设置openvpn监听端口

Which DNS do you want to use with the VPN?
   1) Current system resolvers
   2) 1.1.1.1
   3) Google
   4) OpenDNS
   5) Verisign
DNS [1-5]: 1 #选择DNS

Finally, tell me your name for the client certificate.
Please, use one word only, no special characters.
Client name: client #设置客户端名称

Okay, that was all I needed. We are ready to set up your OpenVPN server now.
Press any key to continue... #任意键继续
...
An updated CRL has been created.
CRL file: /etc/openvpn/server/easy-rsa/pki/crl.pem

Created symlink /etc/systemd/system/multi-user.target.wants/openvpn-iptables.service → /etc/systemd/system/openvpn-iptables.service.
Created symlink /etc/systemd/system/multi-user.target.wants/openvpn-server@server.service → /lib/systemd/system/openvpn-server@.service.

Finished!  #最终看到Finished时表示安装完毕

Your client configuration is available at: /root/client.ovpn #客户端配置文件路径
If you want to add more clients, you simply need to run this script again! 

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

1.2. 添加账号

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

# vi /etc/openvpn/userfile.sh
admin admin123
user user123

截止现在一个超级简单的openvpn服务就已经搭建好了,接下来将使用客户端连接openvpn服务器(以win10为例)

二. 客户端部署使用

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 会有四个菜单选项(添加、撤销、卸载、退出),可根据自身实际情况应用,如下:

Looks like OpenVPN is already installed.

What do you want to do?
   1) Add a new user
   2) Revoke an existing user
   3) Remove OpenVPN
   4) Exit
Select an option [1-4]:

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

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

阅读剩余
THE END