本站文章总数为:165
Search Posts

OpenVPN 3 Linux autoload安装与登陆使用

内容纲要

linux安装教程

官方wiki: https://community.openvpn.net/openvpn/wiki/OpenVPN3Linux
我是centos

yum install yum-plugin-copr
yum copr enable dsommers/openvpn3
yum install openvpn3-client

有些.ovpn不登陆就能用,我的是多节点需要登陆才能使用
所以折腾了好久

OpenVPN 3 Linux and –auth-user-pass

官方文档 https://openvpn.net/blog/openvpn-3-linux-and-auth-user-pass/
官方有点坑没写全,下面是我自己的踩坑

登陆openvpn后台

地址 https://cp-g123-stg.openvpn.com/devices 下载.ovpn文件

下载.ovpn文件

上传到文件夹

上传/etc/openvpn3/autoload 或者任意其他文件夹均可,等下需要新建一个同名xxxx.autoload
.ovpn文件重命名为vpn.ovpn或者任意xxxx.ovpn
然后/etc/openvpn3/autoload 新建一个同名 vpn.autoload 或者同名xxxx.autoload 需要跟你的.ovpn文件同名同文件夹就行

xxxx.autoload文件内容

{
    "autostart": true,
    "user-auth": {
        "autologin": true,
        "username": "填入用户名",
        "password": "填入密码"
    }
}

命令行登陆

openvpn3-autoload --directory 文件夹目录

示例

[root@local autoload]# openvpn3-autoload --directory /etc/openvpn3/autoload
Configuration "tw.ovpn" imported: /net/openvpn/v3/configuration/f90318e7x6a0fx4a7exa8fex2e79c351da71 []
Auto-started "tw.ovpn": /net/openvpn/v3/sessions/85b06482sda8fs4f99s8c26sc57316e81e42

启动

复制上一步获取的

/net/openvpn/v3/configuration/f90318e7x6a0fx4a7exa8fex2e79c351da71

组成命令

openvpn3 session-start --config-path /net/openvpn/v3/configuration/f90318e7x6a0fx4a7exa8fex2e79c351da71

返回如下

[root@local autoload]# openvpn3 session-start --config-path /net/openvpn/v3/configuration/f90318e7x6a0fx4a7exa8fex2e79c351da71
Session path: /net/openvpn/v3/sessions/c07d54b8sb837s4d2as8e1bs6ceb81cfc587
Web based authentication required.
Could not open the URL automatically.
Open this URL to complete the connection: 
     https://xxxxxx.openvpn.com/connect?embedded=true&node_id=xxxxxxxxxxxxxxxxx

Further manage this session using 'openvpn3 session-auth'

提示需要打开url验证,浏览器打开链接登陆验证即可

显示连接成功

[root@local autoload]# openvpn3 sessions-list
-----------------------------------------------------------------------------
        Path: /net/openvpn/v3/sessions/c07d54b8sb837s4d2as8e1bs6ceb81cfc587
     Created: Tue Mar  7 13:47:43 2023                  PID: 28401
       Owner: root                                   Device: tun0
 Config name: tw.ovpn
Session name: jp-hnd.gw.openvpn.com
      Status: Connection, Client connected
-----------------------------------------------------------------------------

断开所有连接

for i in $(openvpn3 sessions-list|grep sessions|awk '{print $2}')
do
openvpn3 session-manage --session-path $i --disconnect
done

重启是disconnect改为restart

附录

前期测试失败报错

未验证

-----------------------------------------------------------------------------
        Path: /net/openvpn/v3/sessions/0784a5dbs0f66s4350s84c2sf22c89dd8cf4
     Created: Tue Mar  7 13:27:40 2023                  PID: 28536
       Owner: root                                   Device: 
 Config name: myvpn
      Status: Web authentication required to connect
openvpn3-linux git地址

https://github.com/OpenVPN/openvpn3-linux

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注