一鍵部署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中添加用戶和密碼,以空格隔開

# cat /etc/openvpn/userfile.sh
guoew guoew123
yakexi yakexi123

截止現在一個超級簡單的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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM