{"id":20911774,"url":"https://github.com/thephoenix77/born2beroot","last_synced_at":"2026-05-18T19:47:48.152Z","repository":{"id":239830367,"uuid":"800719342","full_name":"ThePhoenix77/born2beroot","owner":"ThePhoenix77","description":"Setting up a Debian VM, and implementing different services.","archived":false,"fork":false,"pushed_at":"2024-05-16T15:42:25.000Z","size":1751,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-19T15:39:48.186Z","etag":null,"topics":["administration","apparmor","born2beroot","debian","postfix","postfix-configuration","postfixadmin","ssh","vm"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ThePhoenix77.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-14T21:38:11.000Z","updated_at":"2024-08-10T15:42:31.000Z","dependencies_parsed_at":"2024-05-15T17:32:17.277Z","dependency_job_id":"02170fc2-17e9-452f-8c09-9571e7dd3f07","html_url":"https://github.com/ThePhoenix77/born2beroot","commit_stats":null,"previous_names":["thephoenix77/born2beroot"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThePhoenix77%2Fborn2beroot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThePhoenix77%2Fborn2beroot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThePhoenix77%2Fborn2beroot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThePhoenix77%2Fborn2beroot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThePhoenix77","download_url":"https://codeload.github.com/ThePhoenix77/born2beroot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243302259,"owners_count":20269479,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["administration","apparmor","born2beroot","debian","postfix","postfix-configuration","postfixadmin","ssh","vm"],"created_at":"2024-11-18T14:23:46.942Z","updated_at":"2026-05-18T19:47:43.119Z","avatar_url":"https://github.com/ThePhoenix77.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Born2beroot\n\nWelcome to the \"born2beroot\" project! This README.md file provides an overview of the project, its purpose, features, and how to get started with it.\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Prerequisites](#prerequisites)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Introduction\n\nThe \"born2beroot\" project is an assignment given as part of the School 42 curriculum. It is designed to introduce students to the fundamentals of system administration and server management on a Linux environment.\n\nIn this project, we are tasked with setting up and configuring a Virtual Machine (VM) running a minimal installation of a Linux distribution \n(specifically, Debian). We are required to configure various aspects of the system, including user management, network configuration, security measures, and \nsystem monitoring.\n\n\n## Prerequisites\n\n  * You need a hypervizor type 2 (VirtualBox) to create your Debian VM. [VirtualBox Download Link](https://www.virtualbox.org//wiki/Downloads)  \n  * - Install your Debian OS as \".iso\" file. [Debian OS Download Link] (https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/)\n    - Scroll to the bottom of the website and click debian-xx.x.x-amd64-netinst.iso\n  * Partition your Debian VM and set it up as told by the subject guidelines.\n\n## Installation\n\n  *  Installing Git into your VM:\n    \n      -  Type: ``` apt-get install git -y```\n\n      -  Type: ```git --version to check the Git Version```\n        \n  *  Installing and Configuring SSH (Secure Shell Host):\n    \n      -  Type: ```apt-get install ufw``` to install UFW\n        \n      -  Type: ```sudo ufw enable``` to enable\n        \n      -  Type: ```sudo ufw status numbered``` to check the status of UFW\n        \n      -  Type: ```sudo ufw allow ssh``` to configure the Rules\n        \n      -  Type: ```sudo ufw allow 4242``` to configure the Port Rules\n        \n      -  Type: ```sudo ufw status numbered``` to check the status of UFW 4242 Port\n        \n  *  Installing libpam-pwquality\n    \n      -  Type: ```sudo apt-get install libpam-pwquality``` to install Password Quality Checking Library\n\n## Usage\n ### Mandatory part:\n\n  *  Changing of the Host and Guest Port to 4242:\n    \n      -  Click on your Virtual Machine on the VirtusalBox interface and select Settings\n        \n      -  Click Network then Adapter 1 then Advanced and then click on Port Forwarding\n        \n      -  Click on the green plus button on the top right to add a new rule\n        \n      -  Add a new rule with Host and Guest Port to 4242\n        \n      -  Then head back to your Virtual Machine\n        \n      -  Type: ```sudo systemctl restart ssh``` to restart your SSH Server\n        \n      -  Type: ```sudo service sshd status``` to check your SSH Status\n        \n      -  Open an iTerm and type the following ```ssh your_username@127.0.0.1 -p 4242``` or ```ssh localhost -p 4242```\n        \n      - In case an error occurs, then type ```rm ~/.ssh/known_hosts``` in your iTerm and then retype ```ssh your_username@127.0.0.1 -p 4242```\n    \n      - Lastly type ```exit``` to quit your SSH iTerm Connection\n        \n  *  Setting Password Policy:\n    \n      - Type: ```sudo vim /etc/pam.d/common-password``` to accesss the password configuration file.\n    \n      - Find the line with: ```password\t\trequisite\t\tpam_deny.so``` or ```password\t\trequisite\t\tpam_pwquality.so retry=3```\n    \n      - Add this line: ```minlen=10 ucredit=-1 lcredit=-1 dcredit=-1 maxrepeat=3 reject_username difok=7 enforce_for_root```\n    \n      - Save and Exit Vim\n    \n      - Type in your Virtual Machine ```sudo vim /etc/login.defs```\n    \n      - Find this part: ```PASS_MAX_DAYS 9999 PASS_MIN_DAYS 0 PASS_WARN_AGE 7```\n    \n      - Change that part to ```PASS_MAX_DAYS 30 and PASS_MIN_DAYS 2 keep PASS_WARN_AGE 7 ```\n    \n      - Type: ```sudo reboot``` to reboot the change affects\n        \n  *  Creating a Group:\n    \n      - Type: ```sudo groupadd user42``` to create a group\n    \n      - Type: ```sudo groupadd evaluating``` to create an evaluating group\n    \n      - Type: ```getent group``` to check if the group has been created\n\n\n  *  Creating a User and Assigning Them Into The Group:\n    \n      -  Type: ```cut -d: -f1 /etc/passwd``` to check all local users\n        \n      -  Type: ```sudo adduser new_username``` to create a username - write down your new_username, as you will need this later on\n        \n      -  Type: ```sudo usermod -aG user42 your_username``` to add your username to the user42 group\n        \n      -  Type: ```getent group user42``` to check if the user is the group\n        \n      -  Type: ```groups``` to see which groups the user account belongs to\n        \n      -  Type: ```chage -l your_new_username``` to check if the password rules are working in users\n\n  *  Creating sudo.log:\n    \n      -  Type: ```cd /var/log```\n        \n      -  Type: ```mkdir sudo``` (if it already exists, then continue to the next step).\n        \n      -  Type: ```cd sudo \u0026\u0026 touch sudo.log```\n\n  *  Configuring Sudoers Group:\n    \n      -  Type: ```sudo nano /etc/sudoers``` to go the sudoers file\n        \n      -  Edit your sudoers file to look like the following by adding in all of the defaults in the text below:\n        ```\n          ╔══════════════════════════════════════════════════════════════════════════════╗\n          ║ Defaults\tenv_reset\t\t\t\t\t\t\t ║\n          ║ Defaults\tmail_badpass                                                     ║\n          ║ Defaults\tsecure_path=\"/usr/local/sbin:/usr/local/bin:/usr/bin:/sbin:/bin\" ║\n          ║ Defaults\tbadpass_message=\"Password is wrong, please try again!\"           ║\n          ║ Defaults\tpasswd_tries=3                                                   ║\n          ║ Defaults\tlogfile=\"/var/log/sudo/sudo.log\"                                 ║\n          ║ Defaults\tlog_input, log_output                                            ║\n          ║ Defaults\trequiretty                                                       ║\n          ╚══════════════════════════════════════════════════════════════════════════════╝\n        ```\n\n\n         \n  *   Crontab Configuation:\n    \n      -  Type:``` apt-get install -y net-tools``` to install the netstat tools\n        \n      -  Type: ```cd /usr/local/bin/```\n        \n      -  Type: ```touch monitoring.sh```\n        \n      -  Type: ```chmod 777 monitoring.sh```\n        \n      -  Edit the monitoring script (type: ```sudo vi monitoring.sh```)\n    \n      -  Paste this text below:\n        \n       ``` \n        #!/bin/bash\n        arc=$(uname -a)\n        pcpu=$(grep \"physical id\" /proc/cpuinfo | sort | uniq | wc -l) \n        vcpu=$(grep \"^processor\" /proc/cpuinfo | wc -l)\n        fram=$(free -m | awk '$1 == \"Mem:\" {print $2}')\n        uram=$(free -m | awk '$1 == \"Mem:\" {print $3}')\n        pram=$(free | awk '$1 == \"Mem:\" {printf(\"%.2f\"), $3/$2*100}')\n        fdisk=$(df -BG | grep '^/dev/' | grep -v '/boot$' | awk '{ft += $2} END {print ft}')\n        udisk=$(df -BM | grep '^/dev/' | grep -v '/boot$' | awk '{ut += $3} END {print ut}')\n        pdisk=$(df -BM | grep '^/dev/' | grep -v '/boot$' | awk '{ut += $3} {ft+= $2} END {printf(\"%d\"), ut/ft*100}')\n        cpul=$(top -bn1 | grep '^%Cpu' | cut -c 9- | xargs | awk '{printf(\"%.1f%%\"), $1 + $3}')\n        lb=$(who -b | awk '$1 == \"system\" {print $3 \" \" $4}')\n        lvmu=$(if [ $(lsblk | grep \"lvm\" | wc -l) -eq 0 ]; then echo no; else echo yes; fi)\n        ctcp=$(ss -neopt state established | wc -l)\n        ulog=$(users | wc -w)\n        ip=$(hostname -I)\n        mac=$(ip link show | grep \"ether\" | awk '{print $2}')\n        cmds=$(journalctl _COMM=sudo | grep COMMAND | wc -l)\n        wall \"\t#Architecture: $arc\n\t        #CPU physical: $pcpu\n\t        #vCPU: $vcpu\n\t        #Memory Usage: $uram/${fram}MB ($pram%)\n\t        #Disk Usage: $udisk/${fdisk}Gb ($pdisk%)\n\t        #CPU load: $cpul\n\t        #Last boot: $lb\n\t        #LVM use: $lvmu\n\t        #Connections TCP: $ctcp ESTABLISHED\n\t        #User log: $ulog\n\t        #Network: IP $ip ($mac)\n\t        #Sudo: $cmds cmd\"\n       ```\n\n      -  Type: ```sudo visudo``` to open your sudoers file\n        \n      -  Add in this line: ```your_username ALL=(ALL) NOPASSWD: /usr/local/bin/monitoring.sh``` under where its written ```%sudo ALL=(ALL:ALL) ALL```\n        \n      -  Exit and save your sudoers file\n        \n      -  Type: ```sudo reboot``` in your Virtual Machine to reboot sudo\n        \n      -  Type: ```sudo /usr/local/bin/monitoring.sh``` to execute your script as su (super user)\n        \n      -  Type: ```sudo crontab -u root -e``` to open the crontab and add the rule\n        \n      -  Type the following: ```*/10 * * * * /usr/local/bin/monitoring.sh``` this means that every 10 mins, this script will show\n\n  \n   ### Mandatory part:\n   \n   *  Installing curl:\n      -\tTo get the latest version of PHP, we need to add a different APT repository, Sury's repository.\n     \n      -\tType: ```$ sudo apt install curl``` to install curl\n        \n   *  Retrieving packages with curl\n     \n      - Type: ```$ sudo curl -sSL https://packages.sury.org/php/README.txt | sudo bash -x```\n\n   *  Installing PHP version 8.1:\n     \n        ```\n        $ sudo apt install php8.1\n        $ sudo apt install php-common php-cgi php-cli php-mysql\n        ```\n      - Check php version\n        ```\n        $ php -v\n        ```\n\n   *  Installing Lighttpd\n      - Apache may be installed due to PHP dependencies. Uninstall it if it is to avoid conflicts with lighttpd:\n        ```\n        $ systemctl status apache2\n        $ sudo apt purge apache2\n        ```\n   * Install lighttpd:\n      - Type: $ sudo apt install lighttpd\n      - Check version, start, enable lighttpd and check status:\n        ```\n        $ sudo lighttpd -v\n        $ sudo systemctl start lighttpd\n        $ sudo systemctl enable lighttpd\n        $ sudo systemctl status lighttpd\n        ```\n      - Allow http port (port 80) through UFW:\n        ```\n        $ sudo ufw allow http\n        $ sudo ufw status\n        ```\n       - Then forward host port 8080 to guest port 80 in VirtualBox:\n         \n         Go to VM \u003e\u003e Settings \u003e\u003e Network \u003e\u003e Adapter 1 \u003e\u003e Port Forwarding\n         Add rule for host port 8080 to forward to guest port 80\n     \n       - Test Lighttpd, by going to host machine browser and type in address http://127.0.0.1:8080 or http://localhost:8080. You should see a Lighttpd\n         \"placeholder page\".\n\n        - Get back in VM, activate lighttpd FastCGI module:\n          ```\n          $ sudo lighty-enable-mod fastcgi\n          $ sudo lighty-enable-mod fastcgi-php\n          $ sudo service lighttpd force-reload\n          ```\n       \n        - Test php is working with lighttpd, create a file in /var/www/html named info.php. In that php file, write:\n          ```\n          \u003c?php\n          phpinfo();\n          ?\u003e\n          ```\n        - Save and go to host browser and type in the address http://127.0.0.1:8080/info.php. You should get a page with PHP information.\n\n   * Installing MariaDB\n      - Type: ```$ sudo apt install mariadb-server```\n        \n      - Start, enable and check MariaDB status:\n        ```\n        $ sudo systemctl start mariadb\n        $ sudo systemctl enable mariadb\n        $ systemctl status mariadb\n        ```\n        \n   * MySQL secure installation:\n     - Type: ```$ sudo mysql_secure_installation```\n     - Answer the questions like so (root here does not mean root user of VM, it's the root user of the databases!):\n       ```\n       Enter current password for root (enter for none): \u003cEnter\u003e\n       Switch to unix_socket authentication [Y/n]: Y\n       Set root password? [Y/n]: Y\n       New password: 101Asterix!\n       Re-enter new password: 101Asterix!\n       Remove anonymous users? [Y/n]: Y\n       Disallow root login remotely? [Y/n]: Y\n       Remove test database and access to it? [Y/n]:  Y\n       Reload privilege tables now? [Y/n]:  Y\n\n       ```\n   * Restart MariaDB service:\n\n     - Type: ```$ sudo systemctl restart mariadb```\n     - Enter MariaDB interface\n     - Type: ```$ mysql -u root -p```\n     - Enter MariaDB root password, then create a database for WordPress:\n       ```\n       MariaDB [(none)]\u003e CREATE DATABASE wordpress_db;\n       MariaDB [(none)]\u003e CREATE USER 'admin'@'localhost' IDENTIFIED BY 'WPpassw0rd';\n       MariaDB [(none)]\u003e GRANT ALL ON wordpress_db.* TO 'admin'@'localhost' IDENTIFIED BY 'WPpassw0rd' WITH GRANT OPTION;\n       MariaDB [(none)]\u003e FLUSH PRIVILEGES;\n       MariaDB [(none)]\u003e EXIT;\n       ```\n       \n      - Check that the database was created successfully, go back into MariaDB interface\n      - Type: ```$ mysql -u root -p```\n        \n      - Show databases:\n        ```\n        MariaDB [(none)]\u003e show databases;\n        ```\n        \n      - You should see something like this:\n        ```\n        +--------------------+\n        | Database           |\n        +--------------------+\n        | information_schema |\n        | mysql              |\n        | performance_schema |\n        | wordpress_db       |\n        +--------------------+\n        ```\n        \n      - If the database is there, everything's good!\n\n  * Installing WordPress\n    - We need to install two tools(wget \u0026\u0026 tar):\n      ```\n      $ sudo apt install wget\n      $ sudo apt install tar\n      ```\n      \n    - Download the latest version of Wordpress, extract it and place the contents in /var/www/html/ directory. Then clean up archive and extraction\n      directory:\n      ```\n      $ wget http://wordpress.org/latest.tar.gz\n      $ tar -xzvf latest.tar.gz\n      $ sudo mv wordpress/* /var/www/html/\n      $ rm -rf latest.tar.gz wordpress/\n      ```\n      \n    - Create WordPress configuration file:\n      ```\n      $ sudo mv /var/www/html/wp-config-sample.php /var/www/html/wp-config.php\n      ```\n\n    - Edit /var/www/html/wp-config.php with database info:\n      ```\n      \u003c?php\n      /* ... */\n      /** The name of the database for WordPress */\n      define( 'DB_NAME', 'wordpress_db' );\n\n      /** Database username */\n      define( 'DB_USER', 'admin' );\n\n      /** Database password */\n      define( 'DB_PASSWORD', 'WPpassw0rd' );\n\n      /** Database host */\n      define( 'DB_HOST', 'localhost' );\n      ```\n\n    - Change permissions of WordPress directory to grant rights to web server and restart lighttpd:\n      ```\n      $ sudo chown -R www-data:www-data /var/www/html/\n      $ sudo chmod -R 755 /var/www/html/\n      $ sudo systemctl restart lighttpd\n      ```\n\n    - In host browser, connect to http://127.0.0.1:8080 and finish WordPress installation.\n\n  * Postfix Service:\n    \n     - Postfix definition:\n       \n       ```\n       Postfix is a free and open-source Mail Transfer Agent (MTA).\n       In simpler terms, it's the software onyour server that handles\n       the routing and delivery of emails.\n       \n       Here's a breakdown of what an MTA does:\n       \n       \t-\u003e Receives Incoming Emails: When someone sends an email to an address\n       on your domain (e.g., [email address removed]), Postfix receives that email.\n       \n       \t-\u003e Routes Emails: Postfix figures out where to send the email based on\n       the recipient's address. It might deliver the email directly to a mailbox on\n       your server, or it might send it on to another server.\n       \n       \t-\u003e Delivers Emails: Postfix uses protocols like SMTP (Simple Mail Transfer Protocol)\n       to send emails to their final destination.\n\n       ```\n      - Postfix advantages:\n        ```\n        Postfix is known for being:\n        \n        \t-\u003eFast and Efficient: It can handle large volumes of email traffic efficiently.\n        \n        \t-\u003eSecure: It incorporates security features to protect your server from spam and\n        other threats.\n        \n        \t-\u003e Easy to Administer: It's known for being relatively easy to set up and manage\n        compared to some other MTAs.\n        \n        So, if you want your Debian VM to send and receive emails, installing Postfix\n        is a great option!\n        ```\n      - Postfix installation steps:\n      - Update and Install Packages:\n      - Type: ```$ sudo apt update```\n      - Install Postfix and the mailutils package\n        ```\n        sudo apt install postfix mailutils\n        ```\n\n      - Postfix Configuration:\n      - During installation, Postfix will prompt you with configuration options. Here's what to choose:\n        Visit and follow this video tuorial steps on configuring and testing postfix service on Debian VM [link](https://www.youtube.com/watch?v=oRxk8KWlNRc\u0026t=4s)\n    \n       - Editing main.cf (Optional):\n         While the basic configuration is done, you might want to edit the main Postfix configuration\n         file /etc/postfix/main.cf for further customization.\n         \n       - Type: ```$ sudo nano /etc/postfix/main.cf```\n       - Common customizations in main.cf include:\n         \n         \t/*/ Relay restrictions: Define which networks are allowed to send emails through your server.\n\n         \t/*/ Mailbox location: Specify where incoming emails are stored.\n\n         \t/*/ Alias settings: Create email aliases for forwarding.\n    \n       - Restart Postfix:\n         ```\n         $ sudo systemctl restart postfix\n         ```\n       \n       - Once you've made any edits (or left it as is), save the main.cf file and restart Postfix for the changes to take effect\n       - Type: $ sudo systemctl restart postfix\n\n    * Testing:\n       - You can test your Postfix setup by sending a test email. Here's an example using the mail command:\n         ```echo \"This is a test email\" | mail -s \"Postfix Test\" root```\n\n       - This sends an email with the subject \"Postfix Test\" to the root user on your VM.  Check the root user's mailbox\n          to see if the email arrived.\n\n\n\n## Contributing\n\nIf you would like to contribute to this repository by adding new solutions or improving existing ones, please follow these steps:\n\n1. Fork the repository.\n2. Create a new branch for your changes: `git checkout -b feature/new-solutions`.\n3. Make your changes and commit them: `git commit -m 'Add new solutions'`.\n4. Push to the branch: `git push origin feature/new-solutions`.\n5. Open a pull request.\n\n## License\n\nThis repository is licensed under the license. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthephoenix77%2Fborn2beroot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthephoenix77%2Fborn2beroot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthephoenix77%2Fborn2beroot/lists"}