Push ssh login notification to slack

The following script will help you post an alert when someone ssh to your Linux server

  1. Create a slack webhook
  2. Create a sshrc script as bellow
#------Push notification-------------------------------------#
flag=""
if [ "$alert" = 1 ];then
  now=$(date +"%T")
  co=$(curl --fail --silent --show-error -X POST http://ip-api.com/json/$ip?fields=countryCode | jq -r .countryCode | perl -ne 'print lc') 

  if [ "$co" = null ];then
     flag=":internal:"
  else 
     flag=:flag-$co:
  fi
  curl -X POST --data-urlencode 'payload={"channel": "alerts", "username": 
                 "SSH", "text": "'"$USER"' just logged in on '"$lhn ($host)"' 
                 at '"$now"' from '"$ip"' '"$flag"' ", "icon_emoji": ":ghost:"}' 
                 https://hooks.slack.com/services/url >/dev/null 2>&1
fi

vSphere Suite 6

The products in the vSphere Suite
 

The two core components of vSphere are VMware ESXi® and VMware vCenter Server®

VMware ESXi

The core of the vSphere product suite is the hypervisor, which is the virtualization layer that serves as the foundation for the rest of the product line.

VMware ESXi is the next generation of the VMware virtualization foundation. ESXi installs and runs without the Linux-based Service Console.

Read the rest of this entry

Docker – Part 4 – Manage data in docker containers

Mount a host directory as data volume

You can mount a directory from host to a container

# Create a directory on the host
[root@dockervn ~]# mkdir -p /var/docker/disk01

# Run a container with mounting /var/docker/disk01 to /mnt
[root@dockervn ~]# docker run -i -t -v /var/docker/disk01:/mnt centos /bin/bash
[root@2985e50c258f /]# df -h
Filesystem Size     Used     Avail     Use%     Mounted on
/dev/mapper/docker-253:0-17174473-8dd986c417c6d     10G     241M     9.8G     3%     /
tmpfs 921M 0     921M 0%     /dev
tmpfs 921M 0     921M 0%     /sys/fs/cgroup
/dev/mapper/centos-root                  14G      1.9G 13G      14%     /mnt
shm 64 M 0 64M      0%     /dev/shm

Read the rest of this entry

Docker – Part 3 – Installation

Add docker repo

sudo tee /etc/yum.repos.d/docker.repo <<-‘EOF’
[dockerrepo] name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1 gpgcheck=1 gpgkey=https://yum.dockerproject.org/gpg
EOF

Read the rest of this entry

Docker – Part 2 – Overview

DOCKER COMPOSE

Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a Compose file to configure your application’s services. Then, using a single command, you create and start all the services from your configuration

Using Compose is basically a three-step process.

  • Define your app’s environment with a Dockerfile so it can be reproduced anywhere.
  • Define the services that make up your app in docker-compose.yml so they can be run together in an isolated environment.
  • Lastly, run docker-compose up and Compose will start and run your entire app.
    Read the rest of this entry