Finally I took a fresh installed R7800, installed the luci-wireguard software and did not edit the script at all, just run as it is and got same errors again.
On one hand it is unlikley that I would be the first to find a faulty script,
on the other hand .. on an untouched device, with wireguard software installed, the script should work even if you do not edit it, as far as i can see.
Please don't use a screenshot to show this to us, instead...
Please use the "Preformatted text </>" button for logs, scripts, configs and general console output.
Please edit your post accordingly. Thank you!
P.S. the reason I'm asking is that I'm not seeing any issues with the script on the wiki (quick scan of the code, I could be missing something)... but I'm wondering if maybe something is corrupt in your copy of it... looking at the output will help us determine if that might be the cause of the issue.
The first two lines it complains about are a blank line and a line with clear on it. The complaint about the blank line suggests to me that you have somehow copied the script with CR-LF line terminators, and thus the shell can't find the command <CR> or the command clear<CR>
It works for me. I suggest using the link on the wiki page to download the script directly to your router. Presently that url is as show below. Run this command in a ssh session on the router.
still a little bit a mystery, as I downloaded it (chrome, on a windows pc) and did not edit anything. just put the file on the router via WinSCP .. and go.
I would be gratefull for any explanation / workaround.
thx m
this is the output of the "cat" command. I took the file i downloaded with windows pc / chrome / winscp transfer:
root@OpenWrt:~# cat /root/s2s_combined_win_download.sh
#!/bin/sh
#
# s2s_combined.sh: create configuration scripts that set up a
# site-to-site VPN between two OpenWrt hosts using wireguard.
# The site configurations are symmetric, each is a server with the
# other as a peer.
#
# This script generates two script files, one for each site. The
# generated files contain matched pre-shared keys and private/public key
# values for the two sites.
#
# Run this script on one of the routers (site A for example), then
# copy the generated script for the other site to the other router.
# Run the appropriate script on each router: '/tmp/site-<hostname>.sh'
#
# After running the generated scripts, DELETE the scripts, so that
# nobody copies them and steals the keys. The keys are stored in the
# network configuration files, which you are already protecting since
# they have other confidential information such as wifi passwords, TLS
# server keys, etc.
#
# The generated scripts configure a wireguard tunnel that carries IPv4
# and IPv6 through the tunnel. It routes the other site's IPv6 ULA
# range through the tunnel, plus one IPv4 range. You can add more
# routed networks later through LuCI or uci.
#
clear
echo "======================================"
echo "| Automated WireGuard Script |"
echo "| Site-to-Site VPN |"
echo "| Script generator |"
echo "======================================"
echo -n "Defining variables... "
# Set the following values as needed to configure the generated scripts:
#
# Make this non-empty if you want to create scripts that only show
# the configuration and don't actually set it.
WG_TRIAL=""
# The hostnames of the two OpenWrt routers. Use a dynamic DNS service
# if needed so that your routers can find each other.
WG_SITE_A_HOSTNAME="siteA.dynamic-dns.net"
WG_SITE_B_HOSTNAME="siteB.dynamic-dns.net"
# The description
WG_SITE_A_DESCRIPTION="Site A, ${WG_SITE_A_HOSTNAME}"
WG_SITE_B_DESCRIPTION="Site B, ${WG_SITE_B_HOSTNAME}"
# The interface names at each site
WG_SITE_A_IF="wg_s2s_a"
WG_SITE_B_IF="wg_s2s_b"
WG_PORT="51820"
# The IPv4 range at each site.
# Site A will route traffic to WG_SITE_B_LAN_RANGE through the tunnel
# and vice-versa for site B
WG_SITE_A_LAN_RANGE="192.168.0.0/24"
WG_SITE_B_LAN_RANGE="192.168.1.0/24"
# The IPv6 ULA prefixes for each host. The tunnel will be configured
# to route to the peer's ULA addresses. Get this with
# "uci get network.globals.ula_prefix |sed -e 's,::/.*,,'"
WG_SITE_A_ULA_PREFIX="fdff:ffff:ffff"
WG_SITE_B_ULA_PREFIX="fdee:eeee:eeee"
# Route the IPv6 ULA prefix for the remote site through the tunnel
WG_SITE_A_LAN_RANGE6="${WG_SITE_A_ULA_PREFIX}::/48"
WG_SITE_B_LAN_RANGE6="${WG_SITE_B_ULA_PREFIX}::/48"
# The firewall zone names at each site (the VPN tunnel endpoints are placed
# in these zones)
WG_SITE_A_VPN_ZONE=vpn
WG_SITE_B_VPN_ZONE=vpn
# The firewall WAN zone names at each site, used to configure WAN
# firewall ingress rules to accept wireguard traffic on the chosen port
WG_SITE_A_WAN_ZONE=wan
WG_SITE_B_WAN_ZONE=wan
# You probably don't need to change these unless you don't like these
# internal names
WG_SITE_A_CONFIG_NAME=s2s_vpn_site_a
WG_SITE_B_CONFIG_NAME=s2s_vpn_site_b
WG_FW_RULE_ID="wg_s2s_${WG_PORT}"
echo "Done"
if [ ! -z "${WG_TRIAL}" ]; then
ECHO="echo echo"
else
ECHO="echo"
fi
cleanup() {
echo -n "Removing temporary key files... "
rm -f /tmp/wg_site_a.key /tmp/wg_site_a.pub
rm -f /tmp/wg_site_b.key /tmp/wg_site_b.pub
rm -f /tmp/wg_site_a_and_b.psk
echo "Done"
}
trap cleanup EXIT
cd /tmp
# Generate keys
umask go=
echo -n "Generating WireGuard keys for sites A and B... "
wg genkey | tee wg_site_a.key | wg pubkey > wg_site_a.pub
wg genkey | tee wg_site_b.key | wg pubkey > wg_site_b.pub
wg genpsk > wg_site_a_and_b.psk
# Site_A keys
WG_SITE_A_KEY="$(cat wg_site_a.key)"
WG_SITE_A_PUB="$(cat wg_site_a.pub)"
# Site_B keys
WG_SITE_B_KEY="$(cat wg_site_b.key)"
WG_SITE_B_PUB="$(cat wg_site_b.pub)"
# Pre-shared key known by both
WG_PSK="$(cat wg_site_a_and_b.psk)"
echo "Done"
create_site_config()
{
LOCAL_DESCRIPTION="${1}"
LOCAL_VPN_ZONE="${2}"
LOCAL_IF="${3}"
LOCAL_WAN_ZONE="${4}"
LOCAL_KEY="${5}"
LOCAL_HOSTNAME="${6}"
REMOTE_CONF="${7}"
REMOTE_PUB="${8}"
REMOTE_PSK="${9}"
REMOTE_LAN_RANGE="${10}"
REMOTE_LAN_RANGE6="${11}"
REMOTE_HOSTNAME="${12}"
REMOTE_DESCRIPTION="${13}"
if [ -z "$REMOTE_DESCRIPTION" ]; then
echo not enough args to subroutine 1>&2
exit 1
fi
echo "#!/bin/sh"
echo "clear"
echo "echo ======================================"
echo "echo \"| Automated WireGuard Script |\""
echo "echo \"| Site-to-Site VPN |\""
echo "echo \"| Configuration |\""
echo "echo ======================================"
echo "echo Generated to configure \"${LOCAL_HOSTNAME}\" to tunnel with \"${REMOTE_HOSTNAME}\""
echo "echo -n Creating firewall rule for WAN ingress..."
${ECHO} uci del_list firewall.${LOCAL_VPN_ZONE}.network=\"${LOCAL_IF}\"
${ECHO} uci add_list firewall.${LOCAL_VPN_ZONE}.network=\"${LOCAL_IF}\"
${ECHO} uci -q delete firewall.${WG_FW_RULE_ID}
${ECHO} uci set firewall.${WG_FW_RULE_ID}=\"rule\"
${ECHO} uci set firewall.${WG_FW_RULE_ID}.name=\"Allow-WireGuard-${WG_PORT}\"
${ECHO} uci set firewall.${WG_FW_RULE_ID}.src=\"${LOCAL_WAN_ZONE}\"
${ECHO} uci set firewall.${WG_FW_RULE_ID}.dest_port=\"${WG_PORT}\"
${ECHO} uci set firewall.${WG_FW_RULE_ID}.proto=\"udp\"
${ECHO} uci set firewall.${WG_FW_RULE_ID}.target=\"ACCEPT\"
${ECHO} uci commit firewall
${ECHO} service firewall restart
echo "echo Done"
# Configure network, $LOCAL_DESCRIPTION tunnel endpoint
echo "echo -n Configure wireguard interface \"${LOCAL_IF}\"..."
${ECHO} uci -q delete network.${LOCAL_IF}
${ECHO} uci set network.${LOCAL_IF}=\"interface\"
${ECHO} uci set network.${LOCAL_IF}.proto=\"wireguard\"
${ECHO} uci set network.${LOCAL_IF}.private_key=\"${LOCAL_KEY}\"
${ECHO} uci set network.${LOCAL_IF}.listen_port=\"${WG_PORT}\"
echo "echo Done"
# Add local site's ideas about remote site
echo "echo -n Configure peer \"${REMOTE_DESCRIPTION}\"..."
${ECHO} uci -q delete network.${REMOTE_CONF}
${ECHO} uci set network.${REMOTE_CONF}=\"wireguard_${LOCAL_IF}\"
${ECHO} uci set network.${REMOTE_CONF}.public_key=\"${REMOTE_PUB}\"
${ECHO} uci set network.${REMOTE_CONF}.preshared_key=\"${REMOTE_PSK}\"
${ECHO} uci set network.${REMOTE_CONF}.description=\""${REMOTE_DESCRIPTION}"\"
${ECHO} uci add_list network.${REMOTE_CONF}.allowed_ips=\"${REMOTE_LAN_RANGE}\"
${ECHO} uci add_list network.${REMOTE_CONF}.allowed_ips=\"${REMOTE_LAN_RANGE6}\"
${ECHO} uci set network.${REMOTE_CONF}.route_allowed_ips=\'1\'
${ECHO} uci set network.${REMOTE_CONF}.persistent_keepalive=\'25\'
${ECHO} uci set network.${REMOTE_CONF}.endpoint_host=\"${REMOTE_HOSTNAME}\"
${ECHO} uci set network.${REMOTE_CONF}.endpoint_port=\"${WG_PORT}\"
${ECHO} uci commit network
${ECHO} service network restart
echo "echo Done"
echo "echo ======================================"
echo "echo \"| Next steps |\""
echo "echo ======================================"
echo "echo Remove this script: \"\$0\""
echo "echo It contains copies of your secret keys that"
echo "echo you do not need anymore, because they are now in the network"
echo "echo configuration files. Delete the script to avoid key theft."
}
echo -n "Creating configuration script for \"${WG_SITE_A_DESCRIPTION}\" ... "
create_site_config \
"${WG_SITE_A_DESCRIPTION}" \
"${WG_SITE_A_VPN_ZONE}" \
"${WG_SITE_A_IF}" \
"${WG_SITE_A_WAN_ZONE}" \
"${WG_SITE_A_KEY}"\
"${WG_SITE_A_HOSTNAME}"\
"${WG_SITE_B_CONFIG_NAME}" \
"${WG_SITE_B_PUB}" \
"${WG_PSK}" \
"${WG_SITE_B_LAN_RANGE}" \
"${WG_SITE_B_LAN_RANGE6}" \
"${WG_SITE_B_HOSTNAME}" \
"${WG_SITE_B_DESCRIPTION}" >site-${WG_SITE_A_HOSTNAME}.sh
chmod u+x site-${WG_SITE_A_HOSTNAME}.sh
echo "Done"
echo -n "Creating configuration script for \"${WG_SITE_B_DESCRIPTION}\" ... "
create_site_config \
"${WG_SITE_B_DESCRIPTION}" \
"${WG_SITE_B_VPN_ZONE}" \
"${WG_SITE_B_IF}" \
"${WG_SITE_B_WAN_ZONE}" \
"${WG_SITE_B_KEY}"\
"${WG_SITE_B_HOSTNAME}"\
"${WG_SITE_A_CONFIG_NAME}" \
"${WG_SITE_A_PUB}" \
"${WG_PSK}" \
"${WG_SITE_A_LAN_RANGE}" \
"${WG_SITE_A_LAN_RANGE6}" \
"${WG_SITE_A_HOSTNAME}" \
"${WG_SITE_A_DESCRIPTION}" >site-${WG_SITE_B_HOSTNAME}.sh
chmod u+x site-${WG_SITE_B_HOSTNAME}.sh
echo "Done"
echo "======================================"
echo "| Next steps |"
echo "======================================"
echo "1. Copy /tmp/site-${WG_SITE_A_HOSTNAME}.sh to ${WG_SITE_A_HOSTNAME} and run it there,"
echo " then delete all copies of it to protect your keys."
echo "2. Copy /tmp/site-${WG_SITE_B_HOSTNAME}.sh to ${WG_SITE_B_HOSTNAME} and run it there,"
echo " then delete all copies of it to protect your keys."
echo "======================================"
if [ ! -z "${WG_TRIAL}" ]; then
echo "========================================="
echo "| Trial mode, scripts are nonfunctional |"
echo "========================================="
fi
For comparison, this is the same command with the file i downloaded the way mk24 suggested which is working:
root@OpenWrt:~# wget -O s2s_combined.sh https://openwrt.org/_export/code/docs/guide-user/services/vpn/wireguard/site-to-site?codeblock=1
Downloading 'https://openwrt.org/_export/code/docs/guide-user/services/vpn/wireguard/site-to-site?codeblock=1'
Connecting to 64.226.122.113:443
Writing to 's2s_combined.sh'
Download completed (9373 bytes)
root@OpenWrt:~# cat /root/s2s_combined_win_download.sh
#!/bin/sh
#
# s2s_combined.sh: create configuration scripts that set up a
# site-to-site VPN between two OpenWrt hosts using wireguard.
# The site configurations are symmetric, each is a server with the
# other as a peer.
#
# This script generates two script files, one for each site. The
# generated files contain matched pre-shared keys and private/public key
# values for the two sites.
#
# Run this script on one of the routers (site A for example), then
# copy the generated script for the other site to the other router.
# Run the appropriate script on each router: '/tmp/site-<hostname>.sh'
#
# After running the generated scripts, DELETE the scripts, so that
# nobody copies them and steals the keys. The keys are stored in the
# network configuration files, which you are already protecting since
# they have other confidential information such as wifi passwords, TLS
# server keys, etc.
#
# The generated scripts configure a wireguard tunnel that carries IPv4
# and IPv6 through the tunnel. It routes the other site's IPv6 ULA
# range through the tunnel, plus one IPv4 range. You can add more
# routed networks later through LuCI or uci.
#
clear
echo "======================================"
echo "| Automated WireGuard Script |"
echo "| Site-to-Site VPN |"
echo "| Script generator |"
echo "======================================"
echo -n "Defining variables... "
# Set the following values as needed to configure the generated scripts:
#
# Make this non-empty if you want to create scripts that only show
# the configuration and don't actually set it.
WG_TRIAL=""
# The hostnames of the two OpenWrt routers. Use a dynamic DNS service
# if needed so that your routers can find each other.
WG_SITE_A_HOSTNAME="siteA.dynamic-dns.net"
WG_SITE_B_HOSTNAME="siteB.dynamic-dns.net"
# The description
WG_SITE_A_DESCRIPTION="Site A, ${WG_SITE_A_HOSTNAME}"
WG_SITE_B_DESCRIPTION="Site B, ${WG_SITE_B_HOSTNAME}"
# The interface names at each site
WG_SITE_A_IF="wg_s2s_a"
WG_SITE_B_IF="wg_s2s_b"
WG_PORT="51820"
# The IPv4 range at each site.
# Site A will route traffic to WG_SITE_B_LAN_RANGE through the tunnel
# and vice-versa for site B
WG_SITE_A_LAN_RANGE="192.168.0.0/24"
WG_SITE_B_LAN_RANGE="192.168.1.0/24"
# The IPv6 ULA prefixes for each host. The tunnel will be configured
# to route to the peer's ULA addresses. Get this with
# "uci get network.globals.ula_prefix |sed -e 's,::/.*,,'"
WG_SITE_A_ULA_PREFIX="fdff:ffff:ffff"
WG_SITE_B_ULA_PREFIX="fdee:eeee:eeee"
# Route the IPv6 ULA prefix for the remote site through the tunnel
WG_SITE_A_LAN_RANGE6="${WG_SITE_A_ULA_PREFIX}::/48"
WG_SITE_B_LAN_RANGE6="${WG_SITE_B_ULA_PREFIX}::/48"
# The firewall zone names at each site (the VPN tunnel endpoints are placed
# in these zones)
WG_SITE_A_VPN_ZONE=vpn
WG_SITE_B_VPN_ZONE=vpn
# The firewall WAN zone names at each site, used to configure WAN
# firewall ingress rules to accept wireguard traffic on the chosen port
WG_SITE_A_WAN_ZONE=wan
WG_SITE_B_WAN_ZONE=wan
# You probably don't need to change these unless you don't like these
# internal names
WG_SITE_A_CONFIG_NAME=s2s_vpn_site_a
WG_SITE_B_CONFIG_NAME=s2s_vpn_site_b
WG_FW_RULE_ID="wg_s2s_${WG_PORT}"
echo "Done"
if [ ! -z "${WG_TRIAL}" ]; then
ECHO="echo echo"
else
ECHO="echo"
fi
cleanup() {
echo -n "Removing temporary key files... "
rm -f /tmp/wg_site_a.key /tmp/wg_site_a.pub
rm -f /tmp/wg_site_b.key /tmp/wg_site_b.pub
rm -f /tmp/wg_site_a_and_b.psk
echo "Done"
}
trap cleanup EXIT
cd /tmp
# Generate keys
umask go=
echo -n "Generating WireGuard keys for sites A and B... "
wg genkey | tee wg_site_a.key | wg pubkey > wg_site_a.pub
wg genkey | tee wg_site_b.key | wg pubkey > wg_site_b.pub
wg genpsk > wg_site_a_and_b.psk
# Site_A keys
WG_SITE_A_KEY="$(cat wg_site_a.key)"
WG_SITE_A_PUB="$(cat wg_site_a.pub)"
# Site_B keys
WG_SITE_B_KEY="$(cat wg_site_b.key)"
WG_SITE_B_PUB="$(cat wg_site_b.pub)"
# Pre-shared key known by both
WG_PSK="$(cat wg_site_a_and_b.psk)"
echo "Done"
create_site_config()
{
LOCAL_DESCRIPTION="${1}"
LOCAL_VPN_ZONE="${2}"
LOCAL_IF="${3}"
LOCAL_WAN_ZONE="${4}"
LOCAL_KEY="${5}"
LOCAL_HOSTNAME="${6}"
REMOTE_CONF="${7}"
REMOTE_PUB="${8}"
REMOTE_PSK="${9}"
REMOTE_LAN_RANGE="${10}"
REMOTE_LAN_RANGE6="${11}"
REMOTE_HOSTNAME="${12}"
REMOTE_DESCRIPTION="${13}"
if [ -z "$REMOTE_DESCRIPTION" ]; then
echo not enough args to subroutine 1>&2
exit 1
fi
echo "#!/bin/sh"
echo "clear"
echo "echo ======================================"
echo "echo \"| Automated WireGuard Script |\""
echo "echo \"| Site-to-Site VPN |\""
echo "echo \"| Configuration |\""
echo "echo ======================================"
echo "echo Generated to configure \"${LOCAL_HOSTNAME}\" to tunnel with \"${REMOTE_HOSTNAME}\""
echo "echo -n Creating firewall rule for WAN ingress..."
${ECHO} uci del_list firewall.${LOCAL_VPN_ZONE}.network=\"${LOCAL_IF}\"
${ECHO} uci add_list firewall.${LOCAL_VPN_ZONE}.network=\"${LOCAL_IF}\"
${ECHO} uci -q delete firewall.${WG_FW_RULE_ID}
${ECHO} uci set firewall.${WG_FW_RULE_ID}=\"rule\"
${ECHO} uci set firewall.${WG_FW_RULE_ID}.name=\"Allow-WireGuard-${WG_PORT}\"
${ECHO} uci set firewall.${WG_FW_RULE_ID}.src=\"${LOCAL_WAN_ZONE}\"
${ECHO} uci set firewall.${WG_FW_RULE_ID}.dest_port=\"${WG_PORT}\"
${ECHO} uci set firewall.${WG_FW_RULE_ID}.proto=\"udp\"
${ECHO} uci set firewall.${WG_FW_RULE_ID}.target=\"ACCEPT\"
${ECHO} uci commit firewall
${ECHO} service firewall restart
echo "echo Done"
# Configure network, $LOCAL_DESCRIPTION tunnel endpoint
echo "echo -n Configure wireguard interface \"${LOCAL_IF}\"..."
${ECHO} uci -q delete network.${LOCAL_IF}
${ECHO} uci set network.${LOCAL_IF}=\"interface\"
${ECHO} uci set network.${LOCAL_IF}.proto=\"wireguard\"
${ECHO} uci set network.${LOCAL_IF}.private_key=\"${LOCAL_KEY}\"
${ECHO} uci set network.${LOCAL_IF}.listen_port=\"${WG_PORT}\"
echo "echo Done"
# Add local site's ideas about remote site
echo "echo -n Configure peer \"${REMOTE_DESCRIPTION}\"..."
${ECHO} uci -q delete network.${REMOTE_CONF}
${ECHO} uci set network.${REMOTE_CONF}=\"wireguard_${LOCAL_IF}\"
${ECHO} uci set network.${REMOTE_CONF}.public_key=\"${REMOTE_PUB}\"
${ECHO} uci set network.${REMOTE_CONF}.preshared_key=\"${REMOTE_PSK}\"
${ECHO} uci set network.${REMOTE_CONF}.description=\""${REMOTE_DESCRIPTION}"\"
${ECHO} uci add_list network.${REMOTE_CONF}.allowed_ips=\"${REMOTE_LAN_RANGE}\"
${ECHO} uci add_list network.${REMOTE_CONF}.allowed_ips=\"${REMOTE_LAN_RANGE6}\"
${ECHO} uci set network.${REMOTE_CONF}.route_allowed_ips=\'1\'
${ECHO} uci set network.${REMOTE_CONF}.persistent_keepalive=\'25\'
${ECHO} uci set network.${REMOTE_CONF}.endpoint_host=\"${REMOTE_HOSTNAME}\"
${ECHO} uci set network.${REMOTE_CONF}.endpoint_port=\"${WG_PORT}\"
${ECHO} uci commit network
${ECHO} service network restart
echo "echo Done"
echo "echo ======================================"
echo "echo \"| Next steps |\""
echo "echo ======================================"
echo "echo Remove this script: \"\$0\""
echo "echo It contains copies of your secret keys that"
echo "echo you do not need anymore, because they are now in the network"
echo "echo configuration files. Delete the script to avoid key theft."
}
echo -n "Creating configuration script for \"${WG_SITE_A_DESCRIPTION}\" ... "
create_site_config \
"${WG_SITE_A_DESCRIPTION}" \
"${WG_SITE_A_VPN_ZONE}" \
"${WG_SITE_A_IF}" \
"${WG_SITE_A_WAN_ZONE}" \
"${WG_SITE_A_KEY}"\
"${WG_SITE_A_HOSTNAME}"\
"${WG_SITE_B_CONFIG_NAME}" \
"${WG_SITE_B_PUB}" \
"${WG_PSK}" \
"${WG_SITE_B_LAN_RANGE}" \
"${WG_SITE_B_LAN_RANGE6}" \
"${WG_SITE_B_HOSTNAME}" \
"${WG_SITE_B_DESCRIPTION}" >site-${WG_SITE_A_HOSTNAME}.sh
chmod u+x site-${WG_SITE_A_HOSTNAME}.sh
echo "Done"
echo -n "Creating configuration script for \"${WG_SITE_B_DESCRIPTION}\" ... "
create_site_config \
"${WG_SITE_B_DESCRIPTION}" \
"${WG_SITE_B_VPN_ZONE}" \
"${WG_SITE_B_IF}" \
"${WG_SITE_B_WAN_ZONE}" \
"${WG_SITE_B_KEY}"\
"${WG_SITE_B_HOSTNAME}"\
"${WG_SITE_A_CONFIG_NAME}" \
"${WG_SITE_A_PUB}" \
"${WG_PSK}" \
"${WG_SITE_A_LAN_RANGE}" \
"${WG_SITE_A_LAN_RANGE6}" \
"${WG_SITE_A_HOSTNAME}" \
"${WG_SITE_A_DESCRIPTION}" >site-${WG_SITE_B_HOSTNAME}.sh
chmod u+x site-${WG_SITE_B_HOSTNAME}.sh
echo "Done"
echo "======================================"
echo "| Next steps |"
echo "======================================"
echo "1. Copy /tmp/site-${WG_SITE_A_HOSTNAME}.sh to ${WG_SITE_A_HOSTNAME} and run it there,"
echo " then delete all copies of it to protect your keys."
echo "2. Copy /tmp/site-${WG_SITE_B_HOSTNAME}.sh to ${WG_SITE_B_HOSTNAME} and run it there,"
echo " then delete all copies of it to protect your keys."
echo "======================================"
if [ ! -z "${WG_TRIAL}" ]; then
echo "========================================="
echo "| Trial mode, scripts are nonfunctional |"
echo "========================================="
fi
I think I found the problem / solution.
It seems to be a WinSCP issue.
One needs to select "Text" when uploading the script to the router.
Keeping / Selecting "Standard" leads to a binary upload and the problems I described. Choosing text leads to successfull script execution.
thx to everybody for identifying the root cause.
Question is .. where to put this information?
I am pretty sure i am not the first unix beginner that faces this problem.
If you copied and pasted the script into a Windows text editor it is going to end up with DOS/Windows line endings as it is saved to a file on Windows. Then I guess that the "text" option of WinSCP removes them (I don't use WinSCP since Windows now has a CLI version of scp). If you use the download link at the top of the text box on the wiki page the file will have UNIX line endings and be suitable to copy directly.
Hi mk24,
i tried it exactly like you described.
I did not edit something, just downloading and uploading. No editing. But using WinSCP to upload in binary mode.
If you edit the file you must save it as "Unix" file with LF line endings (I do it with PSPAd). If you then transfer it with WinSCP in binary mode, it is broken again. If you choose Text / Ascii , everything is working fine.
I still wonder myself why one can not transfer a txt file in binary mode and have the same file on the recvieving site. does not make sense to me either.