NewExtra server protection with Measured Boot & UKI images.View Measured Boot
BlogDocumentationFAQNo Third-Party CookiesContact Us
  • Pricing
Log inSign up
Cloud VPSVDSMemory-Optimized VDSStorage-Optimized VDSWindows VPSBitcoin VPSDDoS ProtectionPrivate Networking (VPC)Floating IPsAdditional Server SupportMicrosoft LicensesDatacenterNetworkDocumentationFAQNo Third-Party CookiesConfidential ComputingSelf-Hosted VPNBlogAboutBrand GuidelinesAffiliatesContact UsLegal & Compliance

Products

  • Pricing
  • Cloud VPS
  • VDS
  • RAM-Optimized VDS
  • Storage-Optimized VDS
  • Windows VPS
  • Bitcoin VPS
  • DDoS Protection
  • Private Networking (VPC)
  • Floating IPs
  • Microsoft Licenses
  • Additional Server Support

Explore

  • Documentation
  • Developers API Docs
  • FAQ
  • Datacenter
  • Network
  • Looking Glass
  • Confidential Computing
  • Cookie Policy
  • Self-Hosted VPN

Company

  • Blog
  • Contact Us
  • About Us
  • Brand Guidelines
  • Affiliates

Legal & Compliance

  • Terms of Service
  • Privacy Policy
  • Data Processing Agreement
  • Acceptable Use Policy
  • Microsoft Software Terms of Use
  • Refund Policy
  • Report Abuse

Products

  • Cloud VPS
  • VDS
  • RAM-Optimized VDS
  • Storage-Optimized VDS
  • Windows VPS
  • Bitcoin VPS
  • DDoS Protection
  • Private Networking (VPC)
  • Floating IPs
  • Microsoft Licenses
  • Additional Server Support
Pricing

Explore

  • Documentation
  • Developers API Docs
  • FAQ
  • Datacenter
  • Network
  • Looking Glass
  • Confidential Computing
  • Cookie Policy
  • Self-Hosted VPN

Company

  • Blog
  • Contact Us
  • About Us
  • Brand Guidelines
  • Affiliates

Legal & Compliance

  • Terms of Service
  • Privacy Policy
  • Data Processing Agreement
  • Acceptable Use Policy
  • Microsoft Software Terms of Use
  • Refund Policy
  • Report Abuse

© VPS.BG Ltd. 2026 · All rights reserved!

Made with passion in Bulgaria · VAT ID: BG203144520

Subscribe to Our Newsletter

Join 5000+ subscribers and receive helpful content, deals and more! We promise no spam - 100% great content. Unsubscribe anytime.

Share Article

#SoftEther
  1. Documentation
  2. /
  3. #SoftEther
  4. /
  5. SoftEther VPN installer on Ubuntu (OpenVZ)

SoftEther VPN installer on Ubuntu (OpenVZ)

Published: 24 April 2022 • 3 min read

#Script#SoftEther

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. Additionally, you can also check out our tutorial on how to install SoftEther VPN on Ubuntu 22.

#!/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

Subscribe to Our Newsletter

Join 5000+ subscribers and receive helpful content, deals and more! We promise no spam - 100% great content. Unsubscribe anytime.

Share Article

Related Content

27 March 2023

How to install WireGuard VPN & add users on Linux OS

Step-by-step tutorial on how to install and configure the WireGuard VPN protocol on a Linux server as well as how to create clients & connect devices.

#Tutorial#WireGuard
26 August 2024

How to create a VPN server with WireGuard and a Windows VPS

In this tutorial you are going to learn how to create your own private VPN server using the WireGuard VPN protocol and a fast Windows VPS.

#Tutorial#Windows#WireGuard
11 January 2024

How to install SoftEther VPN on Ubuntu 22

Learn how to manually install SoftEther VPN on a cloud server running on Ubuntu 22 in our detailed, step-by-step tutorial!

#Tutorial#SoftEther

Protect Your Privacy With A Self-Hosted VPN Server

Create your very own, self-hosted VPN server using our privacy-first cloud infrastructure! Verifiable zero-log policy, advantageous location and guaranteed security.

Configure VPNContact Us