A script that allows you to install and configure OpenConnect and LetsEncrypt on your Ubuntu server in the simplest way.
In the Users Menu, you can add a new user, delete an existing user, change username or password for each user, see the list of all users, see connected users, disconnect a connected user, add a separate configuration for each user.
In the OCSERV Menu, you can check the current status of each OCSERV services that you have created, restart or stop each OCSERV services that you have. view OCSERV log and change the current port.
In the LetsEncrypt Menu, You can add a new certificate, delete a certificate, change the certificate for your desired OCServ(s), Renew your certificates and see the current certificates that you already have.
In the Add Multiple OCServ Menu, You can add multiple OCSERVs! Each of them can have a new domain and a new port. A separate service and configuration will be created for each one. Then, you can use OCSERV Menu to view the status or restart, remove, reconfig each one.
Download and execute the script
wget https://raw.githubusercontent.com/B-andi-T/Openconnect-installer-Full-Management-Menu/main/Ocserv-Installer.sh
chmod +x Ocserv-Installer.sh
./Ocserv-Installer.sh
Now answer a few simple questions and wait for the installation and configuration to finish.
that's it!
Now, if you run the script again, you will be redirected to the menu. At the top of the menu, you can see server specifications, OCServ version and service status. The menu contains most of the options you will need to manage your OCServ.
Please note, if you are using Ubuntu 22.04 and you are unable to connect the client to the server after completing the installation, check the server status and if you see The ""futex facility returned an unexpected error"", select the FIX OCServ Futex Error (Ubuntu 22.04) option from the OCServ menu and Wait for the operation to complete. Then connect the client again
Since ocserv is blocked in some countries (such as Iran), if you live in these countries and want to use ocserv, you can ssh tunnel to your main server through a local server.
for example :
You have a local server (a VPS inside your country) called server A and your destination server where ocserv is installed is called server B. First, make sure OCServ is active on server B without errors.
Run the following command on server A:
ssh -p {SERVER B SSH PORT} -f -N -L 0.0.0.0:{ANY PORT YOU WANT}:{SERVER B IP}:{SERVER B OCSERV PORT} root@{SERVER B IP}
example :
ssh -p 22 -f -N -L 0.0.0.0:2222:2.2.2.2:2222 root@2.2.2.2
-If the firewall is active on your server, you should open the port you are using.
Now connect the client to your local server (such as mobile, computer, etc.). as below:
yourlocalserverIP:PORT
of course you will see the ""untrusted server"" message popup when connecting, and the reason is that you are not connecting directly to the main server where your domain and certificate are located.
If you are happy with my script, you can make me happy too with a small amount of donation!
Cheers!