Configuration (SSH, FW, Node, Nginx)
Basic initial configuration for your VPS
Rifki ahmad fahrezi
After purchasing we have to do initial configuration such as installing firewall, nodejs, nginx and so on.
Remote access configuration via SSH
- Prepare a terminal, you can also use git bash or powershell on Windows
- Login as the
root
user by entering the command
- Update the Linux package
- Create a new user to separate the root user (you could say admin) and other users
- Add the newly created user to the sudo group, then log out of the server
- Log back in with the newly created user
- Check if the user is already in the sudo group, if the command below does not display an error then the user is already in the sudo group
- Create a folder for the SSH key, after running the command make sure the folder is successfully created by running the command
ls -a
- Log out of the server to create an SSH key on our computer (if it already exists, you can skip it)
- Send the SSH key to the server
- Windows
- Mac:
- Linux:
- Log in to the server again as the newly created user
- Turn off logging into the
root
user via SSH, so that the userroot
can only be accessed in the hostinger panel terminal browser, how to open the SSH config file
then search down by clicking the arrow on the keyboard until you see the PermitRootLogin yes
config, then change it to PermitRootLogin no
.
If you have clicked ctrl + x
then press y
to save the changed config
- Restart SSH
- Done!, to make sure you can access the server via SSH and have turned off the
root
user login access via SSH you can log out and log back in as theroot
user and as the newly created user.
If the root
user login fails even though the password is correct, while the login as the newly created user is successful, then we have successfully configured SSH access.
Security configuration (firewall)
A firewall is useful for securing our server from unwanted attacks. Here is how to install a firewall:
- Install firewall
- Whitelist port, the purpose is to give access to certain ports so that they can access the server
- Enable firewall
- Check firewall status
- Add new rules to the firewall to block pings to the server
- Open firewall rules
- Find the
INPUT
block below and add these rules
- Reboot the server, wait a few moments and then try logging in again
Nginx configuration
- install Nginx
- Create an Nginx configuration file, then enter the following text
Change the your_server_ip
with your server IP, If you have to save the changes, click ctrl + x
then y
to save the changes
- Activate the Nginx configuration file that we just created
- Delete the default configuration so that there is no conflict
To check whether the config file is correct, you can run this command
- Restart Nginx
Configure the required packages (Nodejs or Bun)
Now we will install the required packages so that we can run the application on the server
Nodejs Installation
Check if the installation was successful by running node -v
and npm -v
, if you want to use PNPM you can install it by following how to install pnpm here
Bun Installation
In addition to Nodejs you can also use Bun,