From f773a36873cbabc48ea5e521ca54a2c626b83c18 Mon Sep 17 00:00:00 2001 From: yanglc Date: Wed, 30 Aug 2023 09:06:25 +0800 Subject: [PATCH] fix mistake --- wginstall.sh | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/wginstall.sh b/wginstall.sh index 095c6d3..6d60bfc 100644 --- a/wginstall.sh +++ b/wginstall.sh @@ -45,20 +45,18 @@ generate_keys() { echo "正在生成WireGuard私钥和公钥..." wg genkey | tee privatekey | wg pubkey > publickey && cat privatekey && cat publickey echo "生成客户端私钥和公钥" - wg genkey | tee cprivatekey | wg pubkey > cpublickey - client1=$(cat cprivatekey) - client2=$(cat cpublickey) + wg genkey | tee cprivatekey | wg pubkey > cpublickey && cat cprivatekey && cat cpublickey } create_server_config() { # 服务器端配置 read -p "请输入服务器的公网IP地址: " server_public_ip read -p "请输入服务器的内网IP地址: " server_internal_ip - read -p "请输入服务器的内网IPv6地址:(fd86::1/48) " server_internal_ipv6 + read -p "请输入服务器的内网IPv6地址:(fd86::1) " server_internal_ipv6 read -p "请输入WireGuard服务器端口号: " server_port read -p "请输入客户端的公钥: " client_public_key read -p "请输入客户端的内网IP地址: " client_internal_ip - read -p "请输入客户端的内网IPv6地址:(fd86::2/48) " client_internal_ipv6 + read -p "请输入客户端的内网IPv6地址:(fd86::2) " client_internal_ipv6 eth=$(ls /sys/class/net| grep ^e | head -n1) # 创建服务器端配置文件 @@ -77,8 +75,8 @@ create_server_config() { echo "WireGuard服务器端配置文件已成功创建在 /etc/wireguard/wg0.conf。" cat > /etc/wireguard/client.conf <<-EOF [Interface] -PrivateKey = $client1 -Address = client_internal_ip/32,$client_internal_ipv6/128 +PrivateKey = $(cat /etc/wireguard/cprivatekey) +Address = $client_internal_ip/32,$client_internal_ipv6/128 DNS = 8.8.8.8 MTU = 1420 [Peer] @@ -87,7 +85,7 @@ Endpoint = $server_public_ip:$server_port AllowedIPs = 0.0.0.0/0, ::0/0 PersistentKeepalive = 25 EOF - echo "自动生成客户端配置文件在" + echo "自动生成客户端配置文件在 /etc/wireguard/client.conf" } create_client_config() {