Tuesday, December 14, 2021

NMAP - Network Mapper : Scanning Localhost

I am going to use localhost to scan for the ports and the applications that uses...
 
Use the following command to scan localhost
 
$ nmap localhost
 
The result of the execution would be summarized as the image given below...
 

As you can see from the image the list of open ports and the services that uses it....other applications can connect through the port to access the required services...

NMAP - Network Mapper : Scanning entire Network

For scanning the entire network use the following command....
 
Inorder to perform the network scan....you have to know the IP address of the gateway...in my case the IP of the gateway is 192.168.1.1 which is the common gateway IP address that all the network would have by default unless if you have changed it to something else....

so having said a fore mentioned gateway IP, the command for scanning the entire network would be 

$ nmap 192.168.1.*

The result of the command execution would be explained by the image given below....


the above image has all the required information about each of the hosts available in the network.....


NMAP - Network Mapper

NMAP is a opensource network mapper tools, which is used by most of the security professionals to enumerate open ports, applications available on a host in a network.

Before we dig deeper into NMAP, let us first discuss how to install it have our investigation.

Installing NMAP

To install NMAP use the following command
$ sudo apt install nmap



The above picture would tell you how NMAP installed successfully and the same can be confirmed by the following command

$ which nmap

The above command would give the location where the package is installed in your system.


Having NMAP installed is not the point I have started the post... I am going to run thru all the options/switches available in the command as subsequent posts...
 
As part of the tour with NMAP let us start the journey by scanning the localhost first...
 

Monday, December 13, 2021

Installing Nginx Web Server in Ubuntu and a Quick Tour about it

Hi,

In this post we are going to see how to install Nginx web server and perform some actions on it...this would be a quick start guide for those who want to browse about Nginx.

The first and foremost...installating Nginx.

Installing Nginx web server

Use the following commands to install Nginx web server.

$ sudo apt update
$ sudo apt install nginx

Well that is it all about the installation of Nginx...pretty easy right....

Starting Nginx

By default when you install Nginx, the web server would be up and running but when you found that web server is off...how would you turn it on? the answer is the command given below...

$ sudo /etc/init.d/nginx start

Signals of Nginx

With respect to Nginx, the web server can be controlled by signals

  • Signals
    • stop : for fast shutdown
    • quit : for graceful shutdown
    • reload : to reload the configuration changes
    • reopen : to reopen the log files
    • restart : to restart the nginx web server

the signals given above are self explanatory and we will see how to use those signals in the following section

How to? Signal Usages
$ nginx -s stop
$ nginx -s quit
$ nginx -s reload
$ nginx -s reopen
$ nginx -s restart

Structure of the Configuration File

Nginx web server consists of module which are controlled by directives mentioned in the configuration file

There are two types of directives....

  • Directives
    • Simple Directive
      consist of name followed by parameters with space separatThere are two types of directives....ed and terminated by a semi colon
    • Block Directive
      same as simple directive but instead of terminating with the semi colon...this directive is enclosed by set of braces or paranthesis. if a block directive can have other directive other directives inside braces or paranthesis, then it is called context.

Directives placed outside of any contexts are considered to be a part of the main context.

Serving Static Content

The purpose of any web server is to serve contents which is requested through a URL. Nginx is no exception on that and the speciality about Nginx is that we can define the locations where the contents are stored to look for.

For instance, the html files can be served form the location called /var/www/html and the images can be served from a different location such as /var/www/images.

Nginx would be known about these locations via respective entries in the configuration file.

Let us try out some of the entries in the configuration file.

In order to server the html files from the location mentioned above... the configruation file should have a block entry named "location" inside the block entry "server" again which is inside the block entry "http", typically the entry should look like the one given below...

    http{
        server{
            location /login.html{
                root /var/www/
            }
        }
    }

Similar to the entry above, we can have a entry which serves images like the one given below....

    http{
        server{
            location /images{
                root /var/www/images
            }
        }
    }

Having said the above two configurations are in place and nginx server has encountered an url such as...

http://localhost/login.html

Now the nginx websever would refer the configuration details to identify the directory for contents, in this case the the directory would be /var/www and if the server finds the file login.html it would be served to the client.

For the next case assuming the login page referring an image and url for the image resource be like....

http://localhost/images/login.png

Now the nginx server would refer the images directory to server the file login.png.

Once we are sure about the configurations defined in the config file we should now let the web sever know about it.

To make the web server know about the configurations we have to load the configurations defined so far.... To achieve this let us reload the server using the command given below....

$ nginx -s reload

with this we can conclude the static content service provided by the nginx server.

Setting up Proxy Server

Now we are going to talk about a important application of nginx server, which is nginx as a proxy server.

As we all know, a server can be used as a proxy for clients and for servers, to be precise nginx web server can be used as both forward proxy and reverse proxy.

Let us now touch upon these two concepts very briefly...

Forward Proxy

Forward proxy is a concept that is applied on the incoming request form the client for the server.... the proxy server sits in between the client and the actual server that does the real job, in which case the server does not know anything about the actual client.

what the proxy server does is... it intercepts the actual request from the client and mask the IP address as part of the request and forward the request to the actual server for processing.

Now for the actual server the client is the proxy server and not the actual client, the actual server does its work and generate the response and sent it back to the proxy server.

The proxy server receives the response, it unmask the IP address and sent it back to the actual client.

To be precise, forward proxy is for the client and not for the server and to be more precise the forward proxy would normally resides in local network and not on the internet.

Reverse Proxy

Reverse proxy on the other hand is the concept applied on the response generated by the actual server.

Here the clients or the request creators does not know about the actual servers, from the client point of view the proxy server is the actual server that creates the response for the request.

This approach is to protect the servers form the malicious client access.

Rever proxy sits on the internet and not on the local network.

Nginx is designed to be a reverse proxy.

Let us see how these two are done in nginx.

Nginx as Reverse Proxy

Let us now see some examples how Nginx server can be used as a reverse proxy

    http {
        server {
            location /home {
                proxy_pass http://localhost:8080/
            }
            location /images{
                root /var/www/images
            }
        }
    }

from the above example given, the first location uses the proxied server for the mapping /home and for serving images the mapping /images is used which is the local folder.

Nginx as FastCGI proxy

Another application of Nginx server is to proxy the fastCGI server where there application build on various frameworks and languages like PHP would run.

Taking the above configuration as a basis, we can have similar configuration for FastCGI proxying.

We will be using fastcgi_pass directive rather proxy_pass for FastCGI configuration.

    http {
        server {
            location /home {
                fastcgi_pass localhost:8080
            }
            location /images{
                root /var/www/images
            }
        }
    }

Well with this we can conclude the installation of Nginx Server and its quick tour.

Let me know what you feel about this post through comments...

Monday, December 6, 2021

Installing TeamCity Continuous Integration / Continuous Deployment DevOps Environment

Hi,
In this post I am going to talk about installing TeamCity which is a DevOps Continuous Integration and Deployment Server.

Prerequisite(s)
SNoNameVersionDownload PageDirect Link
1Java1.8 or >N/AN/A
2MySql8.0 or >N/AN/A
3Team City2020.1 or >N/AClick to Download

The installation of Java and Mysql is off the topic, if you need a discussion point on that... for MySql let me share the link below to have a detailed explanation on how to install MySql in ubuntu and for Java you can refer any online resources which is appropriate for the operating system that you have.

 
Having said Java and Mysql are installed, let us proceed forward for the installation of Team City

Installation of Team City
Download the package from the prerequisites section and move it to your favorite location.

Use the following command to untar the package to your favorite location

$ tar -xzf TeamCity-2020.1.tar.gz

Now you will have a fully exploded package of Team City and this concludes the installation of Team City Continuous Integration/ Continuous Deployment

We can run team city service with two different modes

1. Evaluation
2. Production

Let us discuss the above mentioned modes in detail

Starting Team City Service
Whether we run team city for evaluation or for prodcution, we should have a database for team city in place.... in our case "teamcity_ci" is the database created in mysql server.

For Evaluation

In order to have Team City to run in Evaluation mode..

Open a terminal window and navigate to the bin directory of Team City and run the command given below....

$ ./runAll.sh start

Now open up a browser and hit the following url

Now the user interface would ask user details to key in and proceeding further you have key in the database details as well....

Top stop the service use the following command...
$ ./runAll.sh stop
 
Well this concludes starting team city service for evaluation 

For Production
To have team city run in production mode we have to use the script teamcity-server.sh which resides in bin directory

$ ./teamcity-server.sh start

Now open up a browser and hit the following url

To stop the service use the following command...
$ ./teamcity-server.sh stop

To know about the options to be used with command just run the following...
$ ./teamcity-server.sh

Well this concludes starting team city service for production

Team City auto start on server startup
This section talks about having team city service up and running during the server startup/reboot

Create a file named "teamcity" under the folder /etc/init.d folder open that file in your favorite text editor, in our case vi editor 
 
The following commands would detail how the file has to be created and edited
 
$ sudo touch /etc/init.d/teamcity
$ sudo vi /etc/init.d/teamcity
 
If one of above two commands prompts for the password, please provide one associated with the user.
 
append the file with following content...

#!/bin/sh
### BEGIN INIT INFO
# Provides: TeamCity autostart
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start teamcity daemon at boot time
# Description: Enable service provided by daemon.
# /etc/init.d/teamcity - startup script for teamcity
### END INIT INFO
# Ensure you enter the right user name that TeamCity will run under
USER="admin" ## CHANGE THIS USER NAME TO MATCH YOUR USERNAME
case $1 in
start)
start-stop-daemon --start -c $USER --exec ./TeamCity-2020-1/bin/teamcity-server.sh start
;;
stop)
start-stop-daemon --start -c $USER --exec ./TeamCity-2020-1/bin/teamcity-server.sh stop
;;
esac
exit 0


Change file permission of "teamcity" in /etc/init.d

If the team city server is up and running stop it first before you make these changes and on terminal fire up the following three commands....
$ sudo chmod +x /etc/init.d/teamcity
$ sudo update-rc.d teamcity defaults
$ sudo /etc/init.d/teamcity start

Well that is it, with this we have concluded the installation of TeamCity CI/CD server.

Hope you had great time reading.

Sunday, December 5, 2021

Installing and Configuring Ansible DevOps Environment in Ubuntu

Hi,
In this post we are going to concentrate on how to install Ansible and how to configure it...
 
Before we proceed on the installation part let me give you a brief note on what Ansible is....
 
Ansible is a radically simple IT automation platform that makes your application and system easier to deploy. Avoid writing scripts or custom code to deploy and update your applications - automate in a language that approaches plain English, using SSH, with no agents to install on remote system.
 
(the above description is inspired/copied from the description given when you add the repository for ansible in ubuntu)
 
Installing Ansible
 
Let us first add the repository 

$ sudo apt-add-repository ppa:ansible/ansible
if the above command prompts you for the password provide one associated with the user


$ sudo apt update
 

$ sudo apt install ansible
 
With this the installation part of ansible is complete, let us now concentrate on configuring it...
 
Configuring Ansible
Before you configure ansible you need identify the hosts that is going to be monitored by ansible.....
 
you can think of it in this way, the host/node where ansible is installed is called control node and the host/node entries that you have in the hosts file are called managed hosts/nodes
 
Using your favorite text editor open up the the file hosts which resides at /etc/ansible
 
$ sudo vi /etc/ansible/hosts

create groups and entries as directed by the image given below....

From the above image....

[servers] is the group which has the nodes to be managed...and you can as many groups as you want.
 
The [all:vars] subgroup tells the hosts/nodes about the interpreter to be used by the servers mentioned.

With this the configuration section of ansible is completed.

Testing Ansible

Let us try some command to see how Ansible works

Open a terminal and fire the commands below to see the output...

$ ansible-inventory --list -y
The above command would give the inventory list specified in the hosts file
 

 

$ ansible all -m ping -u root

This command would give you the ping result of all the hosts/nodes mentioned in the hosts file.


 
Well that is it... with this let us conclude this post.

 

Friday, January 29, 2021

Setting up Linux Desktop Environment using Openbox Window Manager in Ubuntu

Hi,

In this post we are going to see how to build a Custom Linux Desktop Environment from scratch using Openbox Window Manager.

Before we proceed further, if we have a linux system with no desktop environment would be of much help to proceed with ease, if you have one already you can skip the following link which talks about having a linux system with no desktop environment.


Desktop Environment Packages Installation

lightdm : The Display Manager
The first and foremost item in the installation list is the Light Display Manager AKA lightdm, it is a cross desktop display manager...which can be installed using the command given below....

$ sudo apt install lightdm

The installation would take sometime, please hold on till it completes...

openbox-gnome-session : The Session Manager
Runs a GNOME session with Openbox as the window manager

To Install Openbox GNOME Session, key in the following command at the terminal...

$ sudo apt install openbox-gnome-session

openbox : The Window Manager
Openbox is a highly configurable, next generation window manager with extensive standards support

To install openbox, run the command below...

$ sudo apt install openbox

gnome-terminal : The Terminal Emulator
To Install GNOME Terminal Emulator execute the following command

$ sudo apt install gnome-terminal

obmenu : The Openbox Menu
Let us now install Openbox Menu, use the following command to have Ob Menu installed

$ sudo apt install obmenu

gedit : The GNOME Text Editor
Well this is not a part of window manager installation.... we need this utility to configure the desktop environment

Key in the following command at the terminal  to have this utility installed...

$ sudo apt install gedit

tint2 : The System Tray
As we all know the system tray is one of the key features in the desktop environment, which can be made available using the following command...

$ sudo apt install tint2

docky : A Simple Docker
This utility is again a additional ingredient in the desktop environment, which enhances the user experience to an other level...

This utility can be installed using the command given below....

$ sudo apt install docky

nitrogen : Desktop Background Browser and Setter
This utility is used to set the background for the desktop. We can have it installed using the following command...

$ sudo apt install nitrogen

ubuntu-wallpapers : Utility for Wall Papers
This is an accessory to have good images for the background, if you have better images than this utility can give, skip this step of installing...

$ sudo apt install ubuntu-wallpapers

pcmanfm : The File Manager
Inorder to have clear differentiation between folders and files, we should have a file manager in place to handles files differently, well this utility would suffice the need and to install the same execute the following comnand

$ sudo apt install pcmanfm

lxappearance : The Theme Switcher
LXAppearance is the standard theme switcher of LXDE. Users are able to change the theme, icons, and fonts used by applications easily.

Use the following command to install LXAppearance

$ sudo apt install lxappearance 

xcompmgr : The Composite Manager
Xcompmgr is a simple composite manager capable of rendering drop shadows and, with the use of the transset utility, primitive window transparency. Xcompmgr is a lightweight alternative to Compiz and similar composite managers.

To install xcompmgr use the following command

$ sudo apt install xcompmgr

firefox : The Browser
This utility does not require any description....

To install firefox run the command below...

$ sudo apt install firefox

pavucontrol : The PulseAudio Volume Control
PulseAudio Volume Control (pavucontrol) is a simple GTK based volume control tool ("mixer") for the PulseAudio sound server

To install pavucontrol use the following command

$ sudo apt install pavucontrol

volti : The Audio Volume Controller
Volti is a lightweight GTK+ application for controlling audio volume from system tray/notification area.

To install volti, use the command below..

$ sudo apt install volti

lxtask : The Task Manager
LXTask is the standard task manager and system monitor of LXDE. It starts via Ctrl+Alt+Del and is extremely lightweight.

To install lxtask, use the command below...

$ sudo apt install lxtask

gconf-editor : Editor for GConf Configuration Database
GConf-Editor is a tool used for editing the GConf configuration database.

To install GConf Editor, run the following command.

$ sudo apt install gconf-editor

Rebooting Virtual Machine
Now at this stage, we have completed installing the necessary components/packages required to have basic Desktop Environment but I cannot guarantee how they are placed.

To see how and where they are placed let us reboot the system...

$ sudo reboot

The above command would prompt you for the password, please provide one associated with the user.

Initial Look and Feel of the System with Openbox
After you reboot the system, you will have the login screen and the default desktop environment similar to the one given in the images

Login Screen by GNOME


Desktop Environment Selection


Login Screen by Openbox


Keying in Password


The Openbox Desktop Environment


Decorating the Desktop Environment

Crediting(Create and Edit) OpenBox Autostart
1. Open Terminal Emulator from the OpenBox Menu

2. Create a directory named openbox at the location ~/.config using the following command
$ mkdir ~/.config/openbox

3. Create a autostart.sh file at the location ~/.config/openbox/autostart.sh, using the following command..
$ touch ~/.config/openbox/autostart.sh

4. Use the following command to edit the autostart.sh file of openbox
$ gedit ~/.config/openbox/autostart.sh

5. Include the following entires in autostart.sh file
tint2 &
docky &
nitrogen --restore &
xcompmgr &
volti &

6. Save the file autostart.sh

7. Reboot the system

Having done all the mentioned steps, you would have a desktop something like the one shown in the image below....


Editing Openbox Menu
1. Open a Terminal emulator and run the following command
$ obmenu &


You would have the obmenu utility dressed up like the one shown in the image below...


2. Expand Openbox 3


3. Renaming Exit Menu Item

Scroll down and select the Exit menu item, click on the Label field to change the name to Logout



4. Save the entry

5. Creating Reboot and Shutdown Entries..... follow the steps given below to create menu items...

    5.1 Click on New Item form the tool bar and name the new entry as Reboot with command reboot.


    5.2 Click on the New Item again from the tool bar and name the new entry as Shutdown with   command shutdown now



6. You can use the arrow tools to move the menu item up and down according to your needs, well the image below would give you the needs I had....


7. Create a menu item for changing the background

New Item -> Lable : Change Background 
              -> Execute : nitrogen



8. Save the changes and Exit.

The Image below would give you the picture of the menu after the changes....



Positioning Docker on the Left Side
In this section let us reposition the docker which is at the bottom and along with system tray.

1. Click on the anchor icon : when you click on the anchor icon in the docker, you would have a window along with the tool tip saying "Drag to repositon" similar to the one given in the image below...


2. Now click and hold the anchor icon and drag to the any of the sides of  the screen, in my case I would like to have the docker at the left hand side of the screen, the reference image is given below...


3. Set the hiding propery to Intellihide, by default this is set None.



Setting an Icon Theme
In this section, I would like to disclose on how to set an Icon Theme for the desktop. To have one we have to use the package lxappearance

1. Open the Terminal Emulator and key in the following command
$ lxappearance &


You would have a window like the one given below...


2. Click on the Icon Theme tab


3. Select the theme which works for you and Apply


Working on Tint2 Panel Themes
In this section we can discuss on working with Tint2 Panel Themes

1. Click on the Tint2 Settings Icon : On the deep left side of the system tray, you would find an icon left to firefox icon called Tint2 Settings Icon, click the icon to have Tint2 Panel Settings.


2. Close the properties window


3. Now select a theme that works for you, my case I have selected the theme shown in the image below...


4. Set the theme as the default theme by clicking on the "Make default" button given on the top.


Setting the Desktop Background
In this section of discussion, let us deal with setting desktop background.

1. From the ObMenu, select/click the Change Background.


2. Click on preferences


3. Click on Add


4. Navigate to the folder File System : /usr/share/backgrounds and click on select


5. Click OK


6. Select the images you like to set it as desktop background and Apply.


7. Set the fill style to "Zoomed Fill" and Apply



Removing Icons from the system tray
In this section, we talk how to remove the icons that we found on the system tray...

1. Click on the Tint2 Panel Theme Icon on the deep left side of the system tray


2. Click the "Launcher" Tab


3. From the above image you can move the items that you have on the left hand side to the right, in my case I would like to have firefox to be moved from left to right...


4. Remove the desktop name


On the Task bar tab, un check the "show desktop name" property


4. Apply the changes and Click OK, the result of the applied changes is displayed below...


Pin to Dock
This section is a utility section, you can skip if you want.

Open up a terminal and run the following command to pin to dock(right click on the icon to pin it) on docker

$ gedit
$ lxtask
$ pcmanfm




How to change the root password in linux when it is forgotten/to change

This blog is all about changing the root password of the Linux system when it is forgotten or to reset the password...   Let's get it ...