# 一键部署OpenVPN **Repository Path**: itxinfei/openvpn ## Basic Information - **Project Name**: 一键部署OpenVPN - **Description**: 每次部署OpenVPN Server很痛苦,基本上都会出错,现在使用openvpn-install非常方便。 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 4 - **Created**: 2024-04-25 - **Last Updated**: 2025-07-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 一键部署OpenVPN脚本 ## 1、上传脚本到服务器 ``` openvpn-install.sh ``` ## 2、执行./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,直接回车,因为获取到的是容器内IP没意义 This server is behind NAT. What is the public IPv4 address or hostname? Public IP address / hostname: xxx.xxx.xxx.xxx #输入自己的公网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! #安装完毕 Your client configuration is available at: /root/client.ovpn #客户端配置文件路径 If you want to add more clients, you simply need to run this script again! ``` ## 3、云服务器安全组打开UDP端口:1194 ## 4、添加账号 在openvpn目录下的userfile.sh中添加用户和密码 ```bash vim /etc/openvpn/userfile.sh # 添加客户端账号密码,这是我的 pangzhao123 pangzhao123 ``` ## 5、安装客户端OpenVPN-2.6.10-I002-amd64.msi 下载/root/client.ovpn导入客户端 ![输入图片说明](image.png)