Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Monday, June 13, 2022

How to Installing OpenCV from the Source



What is OpenCV

OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library. OpenCV was built to provide a common infrastructure for computer vision applications and to accelerate the use of machine perception in the commercial products. 

Install the required dependencies

apt install build-essential cmake git pkg-config libgtk-3-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev gfortran openexr libatlas-base-dev python3-dev python3-numpy libtbb2 libtbb-dev libdc1394-22-dev 

Clone the OpenCV’s and OpenCV contrib repositories

mkdir ~/opencv_build && cd ~/opencv_build
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git 

Once the download is complete, create a temporary build directory, and switch to it

cd ~/opencv_build/opencv
mkdir build && cd build

Set up the OpenCV build with CMake

cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D INSTALL_C_EXAMPLES=ON \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D OPENCV_GENERATE_PKGCONFIG=ON \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_build/opencv_contrib/modules \
    -D BUILD_EXAMPLES=ON ..

When the CMake build system is finalized, you will see something like below



















Start the compilation process

make -j8

Modify the -j flag according to your processor. If you do not know the number of cores in your processor, you can find it by typing nproc.

The compilation may take several minutes or more, depending on your system configuration. Once it is completed you will see something like below:










Install OpenCV

make install











To verify whether OpenCV has been installed successfully, type the following command and you should see the OpenCV version

pkg-config --modversion opencv4








Tuesday, April 19, 2022

How to Install and configure Conky Widgets on Ubuntu

 

Conky Widgets for Ubuntu
Conky is a free software desktop system monitor for the X Window System. It is available for Linux, FreeBSD, and OpenBSD. Conky is highly configurable and is able to monitor many system variables including the status of the CPU, memory, swap space, disk storage, temperatures, processes, network interfaces, battery power, system messages, e-mail inboxes, Arch Linux updates, many popular music players (MPD, XMMS2, BMPx, Audacious, etc.), weather updates, breaking news, and much more. Unlike system monitors that use high-level widget toolkits to render their information, Conky is drawn directly in an X window. This allows it to be configured such that it consumes relatively few system resources. [Wikipedia]

Prerequisites

  • Ubuntu Linux installed desktop PC
  • Install "conky" and "conky-all" on your PC
Step 01: Install "conky" and "conky-all"

apt install conky conky-all

Step 02: Download conky themes
  • Download URL: URL
  • Unzip it under user home directory
Step 03: Make it to start at startup time
  • Open Tweaks -> Startup Applications
  • Add "conky-startup.sh" script to start at startup
You can manually start with bellow command as well.

./.conky/conky-startup.sh > /dev/null 2>&1
































Note: You may need to change the interface name 






Sunday, November 7, 2021

How to Generate Self-Signed Certificate with your own CA

 

How to Generate Self-Signed Certificate with your own CA

In this blog I am going to demonstrate how to generate a self-sign certificate for your local domain for testing purpose.

Prerequisites 

You need to have a LINUX PC or a server to do this, because this script is wrote in bash. Other than that u have to install openssl package to generate certificate.

Download the self-sign certificate from GITHUB from this Link. Download.

Step:1: Extract the content

tar -xvzf selfsign-cert.tar.gz










Step: 2: Generate CA Certificate

./start
  • Select "Genarate New CA Certificate" option
  • Enter CA Name without space. 

























Step: 3: Generate Host Certificate

./start
  • Select "Genarate New Host Certificate" Option
  • Enter Host Certificate name.
  • Enter Domain list. If you are going to use it for multiple site, you have to mention each hostnames.



























Step: 4: Sign Host Certificate

./start
  • Select "Sign Host certificate" Option
  • Enter Host Certificate you want to sign.
  • Enter CA to sign with.



























Sign Certificate and Private Key are locate in below path.

Signed Certificate Path.......: cert/server/sign/test.vidutech.org.pem
Private Key Path.................: cert/server/key/test.vidutech.org.key

You can use these sign certificate and private key to put in Apache or NGINX.

By installing CA certificate in browser, you can avoid CA certificate warning in browser.   

Friday, October 16, 2020

Ubuntu Server Hardening

 

Ubuntu Server Hardening

  • Set bash history with time stamp for root and other users

Add this to .bashrc

HISTSIZE=500000
HISTFILESIZE=200000
HISTTIMEFORMAT="(%m/%d/%y) %T "

export HISTFILESIZE
export HISTSIZE
export HISTTIMEFORMAT

export PROMPT_COMMAND='history -a'

  • Kernel Parameter setup
Add this to "/etc/sysctl.conf"

net.ipv4.conf.all.rp_filter=1
net.ipv4.conf.all.accept_source_route=0
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.icmp_echo_ignore_broadcasts=1
kernel.exec-shield=1
kernel.randomize_va_space=1
net.core.somaxconn=4096
net.core.rmem_max=16777216
net.core.wmem_max=16777216
net.ipv4.ip_local_port_range=1024 65535
net.ipv4.tcp_tw_recycle=1
net.ipv4.tcp_max_syn_backlog=8192
net.core.netdev_max_backlog=16384
net.core.rmem_max=16777216
net.core.wmem_max=16777216
net.ipv4.tcp_rmem=4096 87380 16777216
net.ipv4.tcp_wmem=4096 16384 16777216
net.ipv4.tcp_syncookies = 1
net.core.netdev_max_backlog=300000
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.tcp_timestamps=0

  • Set Limit security for normal users where application are running.
Add below lines to  this file. /etc/security/limits.conf

root        -    nofile          40000
User1       -    nofile          40000
User2       -    nofile          40000 
 

  •  User Account lock after 3 failed logging attempt

Add this configuration to this configuration. /etc/pam.d/common-auth

auth    required        pam_tally2.so deny=3 unlock_time=60

  •  Set ulimit

Add these lines to .bashrc under required user

ulimit -n 40000
TMOUT=1800
ulimit -c unlimited

  • Secure SSH

Stop ssh login for root user. Add ssh allow users to AllowUsers list

Change these configuration in sshd_conf file. /etc/ssh/sshd_config

PermitRootLogin no
Port 3222
AllowUsers User1 User2