Table of contents

Subscribe to our newsletter.
No spam
100% Great content
Unsubscribe anytime

SoftEther VPN installer on Ubuntu (OpenVZ)

Deploy your own, self-hosted VPN server today and start protecting your privacy! Verifiable zero log policy, dedicated IP address and unlimited device connections!

Our wonderful team of developers has manually built a SoftEther VPN software installer that is capable of working on Ubuntu 20.04 while also being eligible to run inside an OpenVZ container. The software in itself is quite user-friendly and neatly written allowing for an easier concept understanding and supporting our full transparency aims. Because of this, the following code is executed every single time when a private, SoftEther VPN server is purchased and deployed. Additionally, if you are having trouble comprehending or figuring out what each code section is intended to do or how the code is supposed to run in general, you can feel free to contact our exceptional support team as they will be able to assist you with any questions regarding our dedicated VPN servers throughout every step of your way.

#!/bin/bash

#Variables 
AdminUserPass=$(</dev/urandom tr -dc '[:alnum:]' | head -c15; echo "")
HubPass=$(</dev/urandom tr -dc '[:alnum:]' | head -c15; echo "")
VPNUserPass=$(</dev/urandom tr -dc '[:alnum:]' | head -c15; echo "")
IPSecKey=$(shuf -i10000-99999999 -n1)
export DEBIAN_FRONTEND=noninteractive

#Set proper mirrors
mv /etc/apt/sources.list /etc/apt/sources.list_backup
tee /etc/apt/sources.list <<EOF
deb https://mirrors.neterra.net/ubuntu/ focal main restricted universe
deb https://mirrors.neterra.net/ubuntu/ focal-updates main restricted universe
deb https://mirrors.neterra.net/ubuntu/ focal-security main restricted universe multiverse
deb http://archive.canonical.com/ubuntu focal partner
EOF

#Install update/install the needed software. 
apt-get -yq --allow-releaseinfo-change update
apt install -y gcc expect e2fsprogs curl

cd /usr/local/
wget https://github.com/SoftEtherVPN/SoftEtherVPN_Stable/releases/download/v4.38-9760-rtm/softether-vpnserver-v4.38-9760-rtm-2021.08.17-linux-x64-64bit.tar.gz
tar xvf softether-vpnserver-*
cd vpnserver && make

#Append the needed configuration for the service. 
tee /lib/systemd/system/vpnserver.service <<EOF
[Unit]
Description=SoftEther VPN Server
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/vpnserver/vpnserver start
ExecStop=/usr/local/vpnserver/vpnserver stop

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl start vpnserver
systemctl enable vpnserver

#Create and execute an expect file. 
tee /root/expect.sh <<EOF
#!/usr/bin/expect -f

set timeout -1

spawn /usr/local/vpnserver/vpncmd

expect "Select 1, 2 or 3:"

send -- "1\n"
sleep 2
expect "Hostname of IP Address of Destination:"

send -- "\n"
sleep 2
expect "Specify Virtual Hub Name"

send -- "\n"
sleep 2
expect "VPN Server>"

send -- "ServerPasswordSet\n"
sleep 2
expect "Password:"

send -- "$AdminUserPass\n"
sleep 2
expect "Confirm input:"

send -- "$AdminUserPass\n"
sleep 2
expect "VPN Server>"

send -- "HubCreate dedicatedvpn\n"
sleep 2
expect "Password:"

send -- "$HubPass\n"
sleep 2
expect "Confirm input:"

send -- "$HubPass\n"
sleep 2
expect "VPN Server>"

send -- "Hub dedicatedvpn\n"
sleep 2
expect "VPN Server/dedicatedvpn>"

send -- "SecureNatEnable\n"
sleep 2
expect "VPN Server/dedicatedvpn>"

send -- "IPsecEnable\n"
sleep 2
expect "Enable L2TP over IPsec Server Function (yes / no):"

send -- "yes\n"
sleep 2
expect "Enable Raw L2TP Server Function (yes / no):"

send -- "no\n"
sleep 2
expect "Enable EtherIP / L2TPv3 over IPsec Server Function (yes / no):"

send -- "no\n"
sleep 2
expect "Pre Shared Key for IPsec (Recommended: 9 letters at maximum):"

send -- "$IPSecKey\n"
sleep 2
expect "Default Virtual HUB in a case of omitting the HUB on the Username:"

send -- "dedicatedvpn\n"
sleep 2
expect "VPN Server/dedicatedvpn>"

send -- "UserCreate dedicatedvpn\n"
sleep 2
expect "Assigned Group Name:"

send -- "\n"
sleep 2
expect "User Full Name:"

send -- "\n"
sleep 2
expect "User Description:"

send -- "\n"
sleep 2
expect "VPN Server/dedicatedvpn>"

send -- "UserPasswordSet dedicatedvpn\n"
sleep 2
expect "Password:"

send -- "$VPNUserPass\n"
sleep 2
expect "Confirm input:"

send -- "$VPNUserPass\n"
sleep 2
expect "VPN Server/dedicatedvpn>"

send -- "LogDisable\n"
sleep 2
expect "Select Security or Packet:"

send -- "Security\n"
sleep 2
expect "VPN Server/dedicatedvpn>"

send -- "LogDisable\n"
sleep 2
expect "Select Security or Packet:"

send -- "Packet\n"
sleep 2
expect "VPN Server/dedicatedvpn>"

send -- "exit\n"

expect eof
EOF
chmod +x /root/expect.sh && /root/expect.sh

truncate -s 0 /usr/local/vpnserver/security_log/**/*.log
rm -rf /usr/local/vpnserver/server_log/*
chattr +i /usr/local/vpnserver/server_log/

#Configure SSH.
sed -i "s/#Port 22/Port 22000/g" /etc/ssh/sshd_config
systemctl restart sshd

#Remove Bloatware 
apt-get remove -y exim* apache2* python* pwgen tcpdump telnet

#Update the system
printf '\n' | apt-get -yq --allow-releaseinfo-change upgrade
apt-get clean

Deploy a self-hosted VPN server today and protect your privacy!

Configure
Payment methods we accept:
Bitcoin
Lightning Network (Bitcoin)
Credit card
Bank transfer