DevSecOps

Instructions on how to run the DevSecOps server

Provision a linux server(ubuntu)

ensure you have a server with at least 2GB RAM and 2 CPUs use an installation of ubuntu 20.04 for this setup

Access the server

connect to your server via ssh

Set up Linux server

sudo apt update && sudo apt upgrade -y

Configure security settings

sudo apt install ufw sudo ufw allow OpenSSH sudo ufw enable sudo ufw status

Harden SSH configuration

PermitRootLogin no

use SSH key authentication

ssh-keygen -t rsa -b 4096 ssh-copy-id yourusername@yourserver-ip

Install and configure Fail2ban

sudo apt install fail2ban sudo systemctl enable fail2ban sudo systemctl start fail2ban

Environmental setup

Apache web server

sudo apt install apache2 sudo systemctl status apache2”

Database server

sudo apt-get install MySQL sudo apt-get install mysql-server

pyhton3

sudo apt install python3 sudo apt install python3-pip

Install and configure Gitlab

sudo apt-get install -y curl openssh-server ca-certificates tzdata perl curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash sudo EXTERNAL_URL="http://your-server-domain-or-ip" apt-get install gitlab-ce sudo nano /etc/GitLab/GitLab.rb

Set up CI/CD pipeline

create new GitLab project add CI/CD configuration stages:

  • build
  • test
  • deploy

build: stage: build script: - echo "Building the application"

test: stage: test script: - echo "Running tests"

deploy: stage: deploy script: - echo "Deploying the application"

push the configuration to GitLab

git add .gitlab-ci.yml git commit -m "Add CI/CD configuration" git push origin main

deploy application code

sudo git clone https://gitlab.com/stephen/npontu.git /var/www/html/yourapp

configure the web server

sudo systemctl restart apache2

Maintenance

Regular Updates

Update System Packages

sudo apt update && sudo apt upgrade -y Update GitLab

Create Backups

Regularly back up /var/www/html, GitLab data, and configuration files. Use cron jobs or backup solutions to automate this process.

Monitoring Tools

Install monitoring tools like Prometheus or Grafana for tracking server health. Configure alerts for issues such as high CPU usage or low disk space.