Bash 如何通过cURL从openvpn下载ovpn文件

Bash 如何通过cURL从openvpn下载ovpn文件,bash,curl,openvpn,Bash,Curl,Openvpn,我正在尝试通过curl命令对作为服务器的openvpn进行身份验证。我的最终目标是能够像通过浏览器但通过cli一样下载ovpn文件。我可以从浏览器中获取cURL命令,但得到了403 我的curl命令如下所示: curl -iL 'https://192.168.35.229:943/?src=connect' \ -H 'Connection: keep-alive' \ -H 'Accept: text/plain, */*; q=0.01' \ -H 'X-OpenVPN: 1'

我正在尝试通过curl命令对作为服务器的openvpn进行身份验证。我的最终目标是能够像通过浏览器但通过cli一样下载ovpn文件。我可以从浏览器中获取cURL命令,但得到了403

我的curl命令如下所示:

curl -iL 'https://192.168.35.229:943/?src=connect' \
  -H 'Connection: keep-alive' \
  -H 'Accept: text/plain, */*; q=0.01' \
  -H 'X-OpenVPN: 1' \
  -H 'X-Requested-With: XMLHttpRequest' \
  -H 'X-CWS-Proto-Ver: 2' \
  -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
  -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36 OPR/70.0.3728.178' \
  -H 'Origin: https://192.168.35.229:943' \
  -H 'Sec-Fetch-Site: same-origin' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Accept-Language: en-US,en;q=0.9' \
  --data-raw 'username=dummy&password=dummy' \
  --compressed \
  --insecure 

HTTP/1.1 302 Found
Transfer-Encoding: chunked
Set-Cookie: openvpn_sess_c6bec1b42f39a6d1034a54580d5422dc=36bce77626a6e403eb6ae9f02576d460; Expires=Wed, 16 Sep 2020 05:15:12 GMT; Path=/; Secure; HttpOnly
Server: OpenVPN-AS
Location: https://192.168.35.229:943/__session_start__/
Date: Wed, 16 Sep 2020 04:45:12 GMT
X-Frame-Options: SAMEORIGIN
Content-Type: text/html; charset=utf-8

HTTP/1.1 403 Forbidden
Transfer-Encoding: chunked
Date: Wed, 16 Sep 2020 04:45:12 GMT
X-Frame-Options: SAMEORIGIN
Content-Type: text/html; charset=UTF-8
Server: OpenVPN-AS

<html><head><title>Forbidden</title></head><body><h1>Forbidden</h1>Request was forbidden.</body></html>#
响应如下所示:

curl -iL 'https://192.168.35.229:943/?src=connect' \
  -H 'Connection: keep-alive' \
  -H 'Accept: text/plain, */*; q=0.01' \
  -H 'X-OpenVPN: 1' \
  -H 'X-Requested-With: XMLHttpRequest' \
  -H 'X-CWS-Proto-Ver: 2' \
  -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
  -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36 OPR/70.0.3728.178' \
  -H 'Origin: https://192.168.35.229:943' \
  -H 'Sec-Fetch-Site: same-origin' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Accept-Language: en-US,en;q=0.9' \
  --data-raw 'username=dummy&password=dummy' \
  --compressed \
  --insecure 

HTTP/1.1 302 Found
Transfer-Encoding: chunked
Set-Cookie: openvpn_sess_c6bec1b42f39a6d1034a54580d5422dc=36bce77626a6e403eb6ae9f02576d460; Expires=Wed, 16 Sep 2020 05:15:12 GMT; Path=/; Secure; HttpOnly
Server: OpenVPN-AS
Location: https://192.168.35.229:943/__session_start__/
Date: Wed, 16 Sep 2020 04:45:12 GMT
X-Frame-Options: SAMEORIGIN
Content-Type: text/html; charset=utf-8

HTTP/1.1 403 Forbidden
Transfer-Encoding: chunked
Date: Wed, 16 Sep 2020 04:45:12 GMT
X-Frame-Options: SAMEORIGIN
Content-Type: text/html; charset=UTF-8
Server: OpenVPN-AS

<html><head><title>Forbidden</title></head><body><h1>Forbidden</h1>Request was forbidden.</body></html>#
找到HTTP/1.1 302 传输编码:分块 设置Cookie:openvpn_sess_c6bec1b42f39a6d1034a54580d5422dc=36bce77626a6e403eb6ae9f02576d460;Expires=Wed,2020年9月16日05:15:12 GMT;路径=/;保护HttpOnly 服务器:OpenVPN AS 地点:https://192.168.35.229:943/__session_start__/ 日期:2020年9月16日星期三04:45:12 GMT X-Frame-Options:SAMEORIGIN 内容类型:text/html;字符集=utf-8 HTTP/1.1 403禁止 传输编码:分块 日期:2020年9月16日星期三04:45:12 GMT X-Frame-Options:SAMEORIGIN 内容类型:text/html;字符集=UTF-8 服务器:OpenVPN AS 禁止的请求被禁止了#
我在文档中找不到任何关于这方面的示例或说明。有没有办法通过CLI-通过bash脚本实现这一点?

我找到了一个基于的解决方案。curl命令如下所示:

curl-u dummy:dummy-khttps://192.168.35.229:943/rest/GetUserlogin