hwdsl2 / docker-ipsec-vpn-server

Docker image to run an IPsec VPN server, with IPsec/L2TP, Cisco IPsec and IKEv2
https://hub.docker.com/r/hwdsl2/ipsec-vpn-server
Other
6.35k stars 1.38k forks source link

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

Closed k186 closed 2 months ago

k186 commented 2 months ago

任务列表

问题描述 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

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

hwdsl2 commented 2 months ago

@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,才可以生效。

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

k186 commented 2 months ago

已经按照上述流程重新试过了,还是一样的,另外 我直接 用你默认的 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 里面改了 写死了,构建私有 镜像了。谢谢~;目前感觉是我拉的镜像出问题;

k186 commented 2 months ago

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