Skip to main content

Install Softether VPN client on Linux Script

Save the following into a install-softether-vpnclient.sh file and ensure you make it executable (chmod +x install-softether-vpn-client.sh:

#!/usr/bin/env bash
#
# install-softether-client.sh — relocate a built SoftEther VPN *Client* into
# /usr/local/vpnclient, symlink binaries onto PATH, and install a systemd unit.
#
# Usage:  sudo ./install-softether-client.sh /path/to/built/vpnclient
#         (the folder that contains: vpnclient, vpncmd, hamcore.se2)
#
set -euo pipefail

SRC="${1:-}"
DEST="/usr/local/vpnclient"

[ -n "$SRC" ] || { echo "Usage: sudo $0 /path/to/built/vpnclient"; exit 1; }
[ "$(id -u)" -eq 0 ] || { echo "Run with sudo."; exit 1; }

# Validate the source has the pieces that must stay together
for f in vpnclient vpncmd hamcore.se2; do
  [ -e "$SRC/$f" ] || { echo "ERROR: '$SRC' is missing $f — point me at the built vpnclient dir."; exit 1; }
done

echo ">> Installing $SRC -> $DEST"
if [ -e "$DEST" ]; then
  echo ">> $DEST exists; stopping any running client and backing it up."
  "$DEST/vpnclient" stop 2>/dev/null || true
  mv "$DEST" "${DEST}.bak.$(date +%s 2>/dev/null || echo old)" 2>/dev/null || rm -rf "$DEST"
fi

cp -a "$SRC" "$DEST"
chown -R root:root "$DEST"
chmod 700 "$DEST/vpnclient" "$DEST/vpncmd"
chmod 600 "$DEST/hamcore.se2"

echo ">> Symlinking binaries onto PATH (symlinks resolve real path, so hamcore is still found)"
ln -sf "$DEST/vpncmd"    /usr/bin/vpncmd
ln -sf "$DEST/vpnclient" /usr/bin/vpnclient

echo ">> Installing systemd unit: softether-vpnclient.service"
cat > /etc/systemd/system/softether-vpnclient.service <<UNIT
[Unit]
Description=SoftEther VPN Client
After=network-online.target
Wants=network-online.target

[Service]
Type=forking
ExecStart=$DEST/vpnclient start
ExecStop=$DEST/vpnclient stop
Restart=on-failure
RestartSec=3

[Install]
WantedBy=multi-user.target
UNIT

systemctl daemon-reload
systemctl enable --now softether-vpnclient

sleep 2
echo ">> Verifying..."
if vpncmd localhost /CLIENT /CMD About >/dev/null 2>&1; then
  echo "OK — vpncmd can reach the running client service."
  echo "   vpncmd  -> $(readlink -f "$(command -v vpncmd)")"
  systemctl --no-pager --property=ActiveState,SubState show softether-vpnclient | sed 's/^/   /'
else
  echo "WARN: client service not reachable yet. Check: systemctl status softether-vpnclient"
fi

Download the Softether VPN Client for LInux from https://www.softether.org/5-download/ and extract it to a directory of your choice. Then run the script you created above as root (sudo) and point it to the "/vpnclient/ directory of your extracted download:

install-softether-vpnclient.sh /Downloads/softether-vpnclient-v4.44-9807-rtm-2025.04.16-linux-x64-64bit/vpnclient