1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-09-19 18:31:16 +00:00
AdvLabDB/docs/server_setup.adoc

182 lines
3.3 KiB
Text
Raw Normal View History

2022-05-08 15:29:45 +00:00
= Server setup
2022-05-29 19:13:25 +00:00
== Server specifications
2022-06-28 21:55:17 +00:00
The setup was tested on Debian 11.3. It should also work on other Debian based Linux distributions. For distributions not based on Debian, some modifications might be necessary in the setup script `server_setup.py`.
2022-05-08 15:29:45 +00:00
2022-06-28 21:55:17 +00:00
Two CPU cores should be more than enough for the server.
2022-05-08 15:29:45 +00:00
2022-05-29 19:13:25 +00:00
The needed disk space depends on the database size after long usage.
== Setup
. Root setup
.. `ssh` as `root`:
+
2022-05-08 15:29:45 +00:00
[source,bash]
----
ssh root@SERVER_NAME
----
2022-05-29 19:13:25 +00:00
.. Run the following (as root):
+
2022-05-08 15:29:45 +00:00
[source,bash]
----
# Install needed packages
apt update
2022-05-17 09:58:19 +00:00
apt install sudo python3 git -y
2022-05-08 15:29:45 +00:00
# Add a sudo user with the name 'admin'
sudo useradd admin
sudo usermod -aG sudo admin
sudo mkhomedir_helper admin
# Enter a new password for 'admin'
sudo passwd admin
# Break the SSH connection
exit
----
2022-05-29 19:13:25 +00:00
. Admin setup
2022-05-08 15:29:45 +00:00
2022-05-29 19:13:25 +00:00
.. `ssh` again with the new user `admin` and password:
+
2022-05-08 15:29:45 +00:00
[source,bash]
----
ssh admin@SERVER_NAME
----
2022-05-29 19:13:25 +00:00
.. Clone the repository with `git clone` into `/home/admin/advlabdb`.
2022-05-17 09:58:19 +00:00
2022-05-29 19:13:25 +00:00
.. `cd` into the new cloned repository:
+
2022-05-17 09:58:19 +00:00
[source,bash]
----
cd ~/advlabdb
----
2022-08-08 20:52:02 +00:00
.. Settings
2022-05-29 19:13:25 +00:00
2022-08-08 20:52:02 +00:00
... Copy the example file for the settings:
2022-05-29 19:13:25 +00:00
+
2022-05-17 10:46:38 +00:00
[source,bash]
----
2022-08-08 20:52:02 +00:00
cp settings_example.ini settings.ini
2022-05-17 10:46:38 +00:00
----
2022-08-08 20:52:02 +00:00
... Enter your SERVER_NAME in `settings.ini`.
2022-05-17 09:58:19 +00:00
2022-05-29 19:13:25 +00:00
.. Timezone
2022-05-08 15:29:45 +00:00
2022-05-29 19:13:25 +00:00
... List all available timezones:
+
2022-05-17 11:52:46 +00:00
[source,bash]
----
sudo timedatectl list-timezones
----
2022-05-29 19:13:25 +00:00
... Choose your timezone and enter it as showed while listing as your timezone using this command (with Europe/Berlin as example):
+
2022-05-17 11:52:46 +00:00
[source,bash]
----
sudo timedatectl set-timezone Europe/Berlin
----
2022-05-29 19:13:25 +00:00
.. Edit the file `/etc/hostname` with `sudo` such that its content is only your SERVER_NAME.
2022-05-17 11:52:46 +00:00
2022-05-29 19:13:25 +00:00
.. Edit the file `/etc/hosts` with `sudo` such that the first two lines are:
+
2022-05-17 11:52:46 +00:00
[source,bash]
----
127.0.0.1 localhost
127.0.1.1 SERVER_NAME SERVER_NAME_WITHOUT_DOMAIN
----
2022-05-29 19:13:25 +00:00
.. Run the server setup script:
+
[source,bash]
----
python3 advlabdb/scripts/setup/server_setup.py
----
2022-05-29 19:13:25 +00:00
.. The setup script will cause the server to reboot at the end. After the reboot ssh again:
+
[source,bash]
----
ssh admin@SERVER_NAME
----
2022-05-29 19:13:25 +00:00
.. Change working directory to the repository:
+
[source,bash]
----
cd ~/advlabdb
2022-05-29 19:13:25 +00:00
----
.. Run database initialization script:
+
[source,bash]
----
2022-08-09 12:46:48 +00:00
poetry run python3 manage.py setup init-db
----
2022-05-29 19:13:25 +00:00
.. *Done!* Now go to your SERVER_NAME using a browser to verify that everything is working.
2022-05-17 11:52:46 +00:00
2022-05-29 19:13:25 +00:00
== SSH configuration
IMPORTANT: This section is important for security!
2022-05-08 15:29:45 +00:00
2022-05-29 19:13:25 +00:00
=== SSH key
For the authentication using SSH, generate a SSH key pair on your _own machine_ (not on the server) and upload the public key to the server using the command `ssh-copy-id`:
2022-05-08 15:29:45 +00:00
2022-05-29 19:13:25 +00:00
[source,bash]
----
ssh-copy-id -i KEY.pub admin@SERVER_NAME
----
=== SSH configuration file
On the server, open the file `/etc/ssh/sshd_config` with in an editor like `nano` or `vim` with `sudo`, then do the following:
2022-05-08 15:29:45 +00:00
2022-05-29 19:13:25 +00:00
. Disable login to root
+
Change
+
2022-05-08 15:29:45 +00:00
----
PermitRootLogin yes
----
2022-05-29 19:13:25 +00:00
+
2022-05-08 15:29:45 +00:00
to
2022-05-29 19:13:25 +00:00
+
2022-05-08 15:29:45 +00:00
----
PermitRootLogin no
----
2022-05-29 19:13:25 +00:00
. Disable login with password
+
WARNING: Make sure that you did upload your public key to the server for the SSH authentication! Otherwise, you will not be able to login to the server after this change.
+
Change
+
----
#PasswordAuthentication yes
----
2022-05-29 19:13:25 +00:00
+
2022-07-02 22:20:13 +00:00
to
2022-05-29 19:13:25 +00:00
+
----
PasswordAuthentication no
----
2022-05-29 19:13:25 +00:00
. Disable X11Forwarding
+
Change
+
----
X11Forwarding yes
----
2022-05-29 19:13:25 +00:00
+
to
2022-05-29 19:13:25 +00:00
+
----
X11Forwarding no
----