[GH-ISSUE #437] IKEv 客户端每次创建都有默认密码,使用VPN_PROTECT_CONFIG=no 配置不生效 #409

Closed
opened 2026-03-02 08:18:43 +03:00 by kerem · 3 comments
Owner

Originally created by @k186 on GitHub (Jun 29, 2024).
Original GitHub issue: https://github.com/hwdsl2/docker-ipsec-vpn-server/issues/437

任务列表

问题描述
env 里面配置VPN_PROTECT_CONFIG=no 不生效,还是会生成密码;参考 IKEv 管理 利用镜像里面的ikev2.sh 脚本 删除客户端重新配置 还是会生成密码;参考历史 issue 里面先删除已知.vpnconfig配置然后 使用sudo ikev2.sh 会提示 sudo 不存在 报错,重新删掉Ikev 客户端重新生成还是会生成密码在.vpnconfig 文件内;镜像已经从官方源拉的最新的;已经尝试过删除所有配置从头来;还是会生成密码;

期待的正确结果
VPN_PROTECT_CONFIG=no 不生成安装密码

相关配置

# Note: All the variables to this image are optional.
# See README for more information.
# To use, uncomment and replace with your own values.

# Define IPsec PSK, VPN username and password
# - DO NOT put "" or '' around values, or add space around =
# - DO NOT use these special characters within values: \ " '
 VPN_IPSEC_PSK=xxxxxx
 VPN_USER=xxx
 VPN_PASSWORD=xxxx

# Define additional VPN users
# - DO NOT put "" or '' around values, or add space around =
# - DO NOT use these special characters within values: \ " '
# - Usernames and passwords must be separated by spaces
 VPN_ADDL_USERS=xx
 VPN_ADDL_PASSWORDS=xx

# Use a DNS name for the VPN server
# - The DNS name must be a fully qualified domain name (FQDN)
 #VPN_DNS_NAME=vpn.xxx.xyz

# Specify a name for the first IKEv2 client
# - Use one word only, no special characters except '-' and '_'
# - The default is 'vpnclient' if not specified
 VPN_CLIENT_NAME=scalper

# Use alternative DNS servers
# - By default, clients are set to use Google Public DNS
# - Example below shows Cloudflare's DNS service
 #VPN_DNS_SRV1=119.29.29.29
 #VPN_DNS_SRV2=180.76.76.76

# Protect IKEv2 client config files using a password
# - By default, no password is required when importing IKEv2 client configuration
# - Uncomment if you want to protect these files using a random password
 VPN_PROTECT_CONFIG=no
version: '3'

volumes:
  ikev2-vpn-data:

services:
  vpn:
    image: hwdsl2/ipsec-vpn-server
    restart: always
    env_file:
      - /www/wwwroot/ipsecvpn/vpn.env
    ports:
      - "500:500/udp"
      - "4500:4500/udp"
    privileged: true
    hostname: ipsec-vpn-server
    container_name: ipsec-vpn-server
    volumes:
      - /www/wwwroot/ipsecvpn/vpn:/etc/ipsec.d
      - /lib/modules:/lib/modules:ro

服务器信息(请填写以下信息)

  • Docker 主机操作系统: Dibian 10
Originally created by @k186 on GitHub (Jun 29, 2024). Original GitHub issue: https://github.com/hwdsl2/docker-ipsec-vpn-server/issues/437 **任务列表** - [x] 我已阅读 [自述文件](https://github.com/hwdsl2/docker-ipsec-vpn-server/blob/master/README-zh.md) - [x] 我已阅读 [重要提示](https://github.com/hwdsl2/docker-ipsec-vpn-server/blob/master/README-zh.md#重要提示) - [x] 我已按照说明 [配置 VPN 客户端](https://github.com/hwdsl2/docker-ipsec-vpn-server/blob/master/README-zh.md#下一步) - [x] 我检查了 [IKEv1 故障排除](https://github.com/hwdsl2/setup-ipsec-vpn/blob/master/docs/clients-zh.md#ikev1-故障排除),[IKEv2 故障排除](https://github.com/hwdsl2/setup-ipsec-vpn/blob/master/docs/ikev2-howto-zh.md#ikev2-故障排除),[启用日志](https://github.com/hwdsl2/docker-ipsec-vpn-server/blob/master/docs/advanced-usage-zh.md#启用-libreswan-日志) 并查看了 [VPN 状态](https://github.com/hwdsl2/setup-ipsec-vpn/blob/master/docs/clients-zh.md#检查日志及-vpn-状态) - [x] 我搜索了已有的 [Issues](https://github.com/hwdsl2/docker-ipsec-vpn-server/issues?q=is%3Aissue) - [ ] 这个 bug 是关于 IPsec VPN 服务器 Docker 镜像,而不是 IPsec VPN 本身 <!--- 如果你发现了 IPsec VPN 的一个可重复的程序漏洞,请在 https://github.com/libreswan/libreswan 提交一个错误报告。VPN 的相关问题可在 [Libreswan](https://lists.libreswan.org/mailman/listinfo/swan) 或 [strongSwan](https://lists.strongswan.org/mailman/listinfo/users) 用户邮件列表提问,或者搜索比如 [Stack Overflow](https://stackoverflow.com/questions/tagged/vpn) 等网站。 ---> **问题描述** env 里面配置`VPN_PROTECT_CONFIG=no` 不生效,还是会生成密码;参考 IKEv 管理 利用镜像里面的ikev2.sh 脚本 删除客户端重新配置 还是会生成密码;参考历史 issue 里面先删除已知`.vpnconfig`配置然后 使用`sudo ikev2.sh` 会提示 sudo 不存在 报错,重新删掉Ikev 客户端重新生成还是会生成密码在`.vpnconfig` 文件内;镜像已经从官方源拉的最新的;已经尝试过删除所有配置从头来;还是会生成密码; **期待的正确结果** VPN_PROTECT_CONFIG=no 不生成安装密码 **相关配置** ```env # Note: All the variables to this image are optional. # See README for more information. # To use, uncomment and replace with your own values. # Define IPsec PSK, VPN username and password # - DO NOT put "" or '' around values, or add space around = # - DO NOT use these special characters within values: \ " ' VPN_IPSEC_PSK=xxxxxx VPN_USER=xxx VPN_PASSWORD=xxxx # Define additional VPN users # - DO NOT put "" or '' around values, or add space around = # - DO NOT use these special characters within values: \ " ' # - Usernames and passwords must be separated by spaces VPN_ADDL_USERS=xx VPN_ADDL_PASSWORDS=xx # Use a DNS name for the VPN server # - The DNS name must be a fully qualified domain name (FQDN) #VPN_DNS_NAME=vpn.xxx.xyz # Specify a name for the first IKEv2 client # - Use one word only, no special characters except '-' and '_' # - The default is 'vpnclient' if not specified VPN_CLIENT_NAME=scalper # Use alternative DNS servers # - By default, clients are set to use Google Public DNS # - Example below shows Cloudflare's DNS service #VPN_DNS_SRV1=119.29.29.29 #VPN_DNS_SRV2=180.76.76.76 # Protect IKEv2 client config files using a password # - By default, no password is required when importing IKEv2 client configuration # - Uncomment if you want to protect these files using a random password VPN_PROTECT_CONFIG=no ``` ```yml version: '3' volumes: ikev2-vpn-data: services: vpn: image: hwdsl2/ipsec-vpn-server restart: always env_file: - /www/wwwroot/ipsecvpn/vpn.env ports: - "500:500/udp" - "4500:4500/udp" privileged: true hostname: ipsec-vpn-server container_name: ipsec-vpn-server volumes: - /www/wwwroot/ipsecvpn/vpn:/etc/ipsec.d - /lib/modules:/lib/modules:ro ``` **服务器信息(请填写以下信息)** - Docker 主机操作系统: Dibian 10
kerem closed this issue 2026-03-02 08:18:43 +03:00
Author
Owner

@hwdsl2 commented on GitHub (Jun 30, 2024):

@k186 你好!对于你的用例,你可能在创建 Docker 容器时曾经设置过 VPN_PROTECT_CONFIG=yes。请尝试以下步骤:

  1. 确保 /www/wwwroot/ipsecvpn/vpn.env 文件中的变量是 VPN_PROTECT_CONFIG=no.
  2. 删除容器内的 /etc/ipsec.d 目录下的 .vpnconfig 文件。要进入容器,请参见 在容器中运行 Bash shell。或者,对于你的用例,你也可以尝试删除 /www/wwwroot/ipsecvpn/vpn/.vpnconfig.
  3. 编辑容器内的 /etc/ipsec.d/ikev2setup.log,在纸上记下现有的密码,并删除和客户端文件密码有关的行。这一步是可选的。如果不删除也可以,不删除的话,容器的日志(docker logs)仍然会显示客户端配置文件密码,你可以忽略,因为日志显示的是该文件的内容,这个文件是初始安装 IKEv2 时生成的。
  4. (重要)删除并重新创建 Docker 容器。这样你对 env 文件的更改,比如 VPN_PROTECT_CONFIG=no,才可以生效。

在完成后,新创建的(或重新导出的)客户端配置文件导入时将不再需要输入密码。请参见这一小节的管理客户端部分。请注意,之前生成的配置文件仍然有密码保护。

<!-- gh-comment-id:2198615289 --> @hwdsl2 commented on GitHub (Jun 30, 2024): @k186 你好!对于你的用例,你可能在创建 Docker 容器时曾经设置过 `VPN_PROTECT_CONFIG=yes`。请尝试以下步骤: 1. 确保 `/www/wwwroot/ipsecvpn/vpn.env` 文件中的变量是 `VPN_PROTECT_CONFIG=no`. 2. 删除容器内的 `/etc/ipsec.d` 目录下的 `.vpnconfig` 文件。要进入容器,请参见 [在容器中运行 Bash shell](https://github.com/hwdsl2/docker-ipsec-vpn-server/blob/master/docs/advanced-usage-zh.md#%E5%9C%A8%E5%AE%B9%E5%99%A8%E4%B8%AD%E8%BF%90%E8%A1%8C-bash-shell)。或者,对于你的用例,你也可以尝试删除 `/www/wwwroot/ipsecvpn/vpn/.vpnconfig`. 3. 编辑容器内的 `/etc/ipsec.d/ikev2setup.log`,在纸上记下现有的密码,并删除和客户端文件密码有关的行。这一步是可选的。如果不删除也可以,不删除的话,容器的日志(docker logs)仍然会显示客户端配置文件密码,你可以忽略,因为日志显示的是该文件的内容,这个文件是初始安装 IKEv2 时生成的。 4. (重要)删除并重新创建 Docker 容器。这样你对 env 文件的更改,比如 `VPN_PROTECT_CONFIG=no`,才可以生效。 在完成后,新创建的(或重新导出的)客户端配置文件导入时将不再需要输入密码。请参见[这一小节](https://github.com/hwdsl2/docker-ipsec-vpn-server/blob/master/README-zh.md#%E9%85%8D%E7%BD%AE%E5%B9%B6%E4%BD%BF%E7%94%A8-ikev2-vpn)的管理客户端部分。请注意,之前生成的配置文件仍然有密码保护。
Author
Owner

@k186 commented on GitHub (Jul 1, 2024):

已经按照上述流程重新试过了,还是一样的,另外 我直接 用你默认的 docker命令 出来的结果还是会生成终端安装密码;

docker run \
    --name ipsec-vpn-server \
    --restart=always \
    -v ikev2-vpn-data:/etc/ipsec.d \
    -v /lib/modules:/lib/modules:ro \
    -p 500:500/udp \
    -p 4500:4500/udp \
    -d --privileged \
    hwdsl2/ipsec-vpn-server

我直接把 ikev2setup.sh 里面改了 写死了,构建私有 镜像了。谢谢~;目前感觉是我拉的镜像出问题;

<!-- gh-comment-id:2199026692 --> @k186 commented on GitHub (Jul 1, 2024): 已经按照上述流程重新试过了,还是一样的,另外 我直接 用你默认的 docker命令 出来的结果还是会生成终端安装密码; ```shell docker run \ --name ipsec-vpn-server \ --restart=always \ -v ikev2-vpn-data:/etc/ipsec.d \ -v /lib/modules:/lib/modules:ro \ -p 500:500/udp \ -p 4500:4500/udp \ -d --privileged \ hwdsl2/ipsec-vpn-server ``` 我直接把 ikev2setup.sh 里面改了 写死了,构建私有 镜像了。谢谢~;目前感觉是我拉的镜像出问题;
Author
Owner

@k186 commented on GitHub (Jul 1, 2024):

确认了。。。是镜像问题。。。我路由上面有总代理。。拉的还是2022年的镜像。检查镜像里面 脚本发现的。。。。

<!-- gh-comment-id:2199378777 --> @k186 commented on GitHub (Jul 1, 2024): 确认了。。。是镜像问题。。。我路由上面有总代理。。拉的还是2022年的镜像。检查镜像里面 脚本发现的。。。。
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/docker-ipsec-vpn-server#409
No description provided.