This script is a tool designed to simplify the process of setting up your Ubuntu VPS server. It manages the installation of essential packages, Docker, Docker Compose, and, if you want, ERPNext.
This guide aims to assist absolute beginners in using the script.
Before you can use the setup script, you need to perform some initial configurations on your Ubuntu VPS server:
-
Log in to your server using SSH:
To connect to your server, you will need a client application that supports the Secure Shell (SSH) protocol. For Windows users, PowerShell provides an easy way to use SSH. For macOS and Linux, the Terminal application has built-in SSH support.
-
On Windows: Press the Windows key, type 'PowerShell', and press 'Enter'. This will launch Windows PowerShell. Use the following command to connect to your server:
ssh root@your_server_ip
Replace
your_server_ipwith the IP address of your server. The initial user is usually 'root', but if you are using a GDPR-compliant provider like IONOS, you can find the initial user and password in your VPS overview.If you encounter an error message saying
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!, this is due to the SSH client recognizing that the server's fingerprint doesn't match the one it has recorded in theknown_hostsfile. This typically happens when you've reinstalled or reset your server. To resolve this, remove the offending key with this command:ssh-keygen -R "your_server_ip"After running this command, you should be able to connect to your server again.
-
On macOS and Linux: Open Terminal and type the following command, then press 'Enter'. Replace
rootwith your server's username andyour_server_ipwith the IP address of your server.ssh root@your_server_ip
If you encounter an error similar to
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!, you can use the following command to remove the offending key:ssh-keygen -R "your_server_ip"
-
-
Create a new user account with sudo privileges:
On your server, create a new user account and grant it sudo privileges. This will be the user account you'll use to run the script. Here is an example of creating a new user named
your_usernameand adding it to the sudo group:adduser your_username usermod -aG sudo your_username sudo groupadd docker usermod -aG docker your_username
Make sure to replace
your_usernamewith the username you want. -
Install Git on your server:
The setup script requires Git to clone the necessary repositories. Install Git by running:
sudo apt update sudo apt upgrade sudo apt install git reboot
After preparing your server, you can use the setup script as follows:
-
Log in to your server using SSH:
To connect to your server, you will need a client application that supports the Secure Shell (SSH) protocol. For Windows users, PowerShell provides an easy way to use SSH. For macOS and Linux, the Terminal application has built-in SSH support.
-
On Windows: Press the Windows key, type 'PowerShell', and press 'Enter'. This will launch Windows PowerShell.
You can generate an SSH key pair directly in PowerShell. Just paste the following command and press 'Enter':
⚠️ WARNING: If an SSH key already exists at the default location, DO NOT overwrite it. Doing so could invalidate your key on any systems where it's currently in use and potentially lock you out. So if asked to overwirte the key, type 'n' and press 'Enter'. Just skip to the next step if you already have an SSH key pair.ssh-keygen
It will ask for a location to save the keys and a passphrase for added security. You can press 'Enter' to accept the default location and skip the passphrase, but using a passphrase is recommended for added security.
Next, log in to your server and create the
.sshdirectory and theauthorized_keysfile if they don't exist. Use this command:ssh your_username@your_server_ip "mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys"After that, you can copy your public key to your server with the command:
type $env:USERPROFILE\.ssh\id_rsa.pub | ssh your_username@your_server_ip "cat >> .ssh/authorized_keys"
Replace
your_usernameandyour_server_ipwith your server's username and IP address respectively. The public key is now added to the list of authorized keys on your server. After this, you can log in to your server without a password.To login to your server, use the command:
ssh your_username@your_server_ip
-
On macOS and Linux: Open Terminal and type the following command, then press 'Enter'. Replace
your_usernamewith your server's username andyour_server_ipwith the IP address of your server.⚠️ WARNING: If an SSH key already exists at the default location, DO NOT overwrite it. Doing so could invalidate your key on any systems where it's currently in use and potentially lock you out. So if asked to overwirte the key, type 'n' and press 'Enter'. Just skip to the next step if you already have an SSH key pair.ssh your_username@your_server_ip
If you want to set up SSH key-based authentication, follow these commands:
ssh-keygen ssh-copy-id your_username@your_server_ip
The rest of the steps remain the same as mentioned in the previous guide.
-
-
Clone the repository containing the script:
After logging in, clone the repository with the setup script:
git clone https://github.com/NADOOIT/Auto-Ubuntu-VPS-Server-Setup-Script.git cd Auto-Ubuntu-VPS-Server-Setup-Script -
Make the script executable:
The next step is to give the file
setup.sh, the permission to execute as a program. If you skip this step, the system will refuse to run the script and will give you a 'Permission Denied' error.chmod +x setup.sh
-
Run the setup script:
Now you can run the script. This will install Docker, Docker Compose, and, if you choose, ERPNext.
sudo ./setup.sh
You will be asked if you want to install ERPNext. If you want to install it, type 'yes'; otherwise, type 'no'.
After the script is done:
- Portainer: You can access Portainer, which allows you to manage Docker containers, at
http://your-server-ip:9000in a web browser. - ERPNext: If you chose to install ERPNext, it's available at
http://your-server-iponce the Docker containers are operational. If you can't access ERPNext, check whether the Docker containers are running properly.
This script also supports setting up RustDesk Server OSS, a comprehensive remote desktop software, using Docker. Follow these steps to install RustDesk Server on your Ubuntu VPS.
Ensure Docker is installed on your server. RustDesk Server requires specific ports to be open:
- TCP Ports: 21115, 21116, 21117, 21118, 21119
- UDP Port: 21116
These ports facilitate various RustDesk services, including NAT testing, ID registration, heartbeat service, TCP hole punching, connection service, and relay services. Ports 21118 and 21119 are for web client support and can be disabled if not needed.
-
Open Required Ports: Open the required ports in your server's firewall to enable RustDesk functionality and external connectivity. Use the following commands:
sudo ufw allow 21115/tcp sudo ufw allow 21116/tcp sudo ufw allow 21116/udp sudo ufw allow 21117/tcp sudo ufw allow 21118/tcp sudo ufw allow 21119/tcp sudo ufw reload
Note: If you're not using UFW (Uncomplicated Firewall), adjust these commands according to your firewall configuration.
-
Deploy RustDesk using Docker Compose: Navigate to the directory containing the
docker-compose-rustdesk.ymlfile. Run the Docker Compose file to start RustDesk Server OSS components in detached mode:sudo docker-compose -f docker-compose-rustdesk.yml up -d
-
Retrieve the Server Key: After starting the RustDesk services, you need to retrieve the server key. This key is essential for configuring RustDesk clients to connect to your server. To get the key, check the logs of the
hbbscontainer:docker logs hbbs
Look for a line that starts with "Key:". It should look something like this:
Key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=Replace 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=' with the actual key you see in the logs. This key needs to be added to the RustDesk client settings along with your server's address.
-
Configure RustDesk Clients: On each RustDesk client that you want to connect to this server:
- Open RustDesk settings
- Go to the "Network" tab
- Set the "ID Server" to your server's address (e.g., rust.nadooit.de)
- Set the "Key" field to the key you retrieved from the server logs
- Click "Apply" to save the settings
By following these steps, you should have a functioning RustDesk Server OSS installation, with the necessary ports open and the correct key configuration for client connections.