show code js

2024年12月29日 星期日

postgresql

  •  ubuntu 24.04 install postgresql
  • sudo apt install postgresql postgresql-contrib > Y
  • sudo systemctl enable postgresql.service
  • sudo systemctl start postgresql.service
  • test
    • sudo -i -u postgres
    • psql
    • \q
    • exit
  • create user
    • sudo -i -u postgres
    • createuser --interactive
    • >myuser
    • >n,n,n
  • createdb mydb
  • psql
    • sudo -u postgres psql
    • ALTER USER myuser WITH PASSWORD 'pass';
    • GRANT ALL PRIVILEGES ON DATABASE mydb TO myuser;
    • \q
  • connect config
    • sudo nano /etc/postgresql/XX/main/postgresql.conf
      • listen_addresses = '*'
    • sudo nano /etc/postgresql/16/main/pg_hba.conf
      • IPV4
      • host    db       user       ip           mode:md5(trust)
  • firewall config
    • sudo ufw enable
    • sudo ufw start
    • sudo ufw allow ssh
    • sudo ufw allow 5432/tcp
    • sudo ufw status numbered
    • sudo ufw logging on
  • debug can not connect
    • sudo lsof -i :5432
    • test connect
    • psql -h out_host -U user -d database  
  • Note
    • $ sudo -u postgres psql
    • postgres=# CREATE DATABASE yourdbname;
    • postgres=# CREATE USER youruser WITH ENCRYPTED PASSWORD 'yourpass';
    • postgres=# GRANT ALL PRIVILEGES ON DATABASE yourdbname TO youruser;

iTOP

  •  https://www.combodo.com/itop-193
  • docker run -d -p 8080:80 --name=my-itop -v my-itop-conf-volume:/var/www/html/conf -v my-itop-db-volume:/var/lib/mysql vbkunin/itop
  • docker exec my-itop chown www-data:www-data /var/www/html/conf
  • get mysql pass to install:
    • win>
      • docker logs my-itop | Select-String -Pattern "Your MySQL user 'admin' has password:" -Context 1,7
    • linux>
      • docker logs my-itop | grep -A7 -B1 "Your MySQL user 'admin' has password:"
  • http://localhost:8080/ install and use itil

Wazuh

  •  git clone https://github.com/wazuh/wazuh-docker.git -b v4.9.2
  • cd wazuh-docker/single-node/
    • modify docker-compose.yml
      • #change 443 to your port
      • #modify memory or  CPU limit
  • docker-compose -f generate-indexer-certs.yml run --rm generator
  • docker-compose up -d
  • open https://ip:your_port or space(443) to check is running
    • admin:SecretPassword
    • modify default password

  • Agent
    • https://wazuh.com/install/
    • docker ps
    • docker exec -it single-node-wazuh.manager-1 or com-id /bin/bash
    • bash-5.2# /var/ossec/bin/manage_agents
      • ****************************************
      • * Wazuh v4.9.2 Agent manager.          *
      • * The following options are available: *
      • ****************************************
      •    (A)dd an agent (A).
      •    (E)xtract key for an agent (E).
      •    (L)ist already added agents (L).
      •    (R)emove an agent (R).
      •    (Q)uit.
      • Choose your action: A,E,L,R or Q:
    • 1.Press (A) to set a new agent with name (Computer's name), IP (any)
    • 2.Press (L) to find ID 00x
    • 3.Press (E) to create auth key
      • get the auth key to keyin agent on win or linux
      • check wazuh run on services.msc

install ubuntu

  • install ubunto 24.04.1 
  • sudo apt-get install openssh-server
  • sudo systemctl start ssh
  • sudo systemctl enable ssh
  • sudo ufw enable
  • sudo ufw allow ssh
  • sudo reboot
  • sudo apt upgrade -y && sudo apt update -y
  • sudo apt upgrade -y && sudo apt update -y

clamav for linux

  • sudo apt update && sudo apt upgrade
  • sudo apt install clamav clamav-daemon -y 
  • sudo systemctl stop clamav-freshclam.service
  • sudo freshclam
  • sudo systemctl start clamav-freshclam.service
  • #sudo clamscan -r /path/to/folder
  • sudo systemctl enable clamav-daemon
  • sudo systemctl enable clamav-freshclam.service

create ocs on docker

  •  git clone https://github.com/OCSInventory-NG/OCSInventory-Docker-Image
  • cd OCSInventory-Docker-Image
  • cd new_version
  • modify docker-compose.yml config ports
  • PS>docker-compose up -d