CentOS: MySQL-VSFTP authentication – Plus use this FTP directory as your YUM FTP repository.

This how to shows how to use VSFTPD with virtual users that authenticate against a MySQL database. This solution does not scale well because as far as I can tell you cannot have the MySQL database on an isolated server while other several FTP servers use it to authenticate user logins. My understanding is that both VSFTP and MySQL need to reside on the same machine in order for this work.If I am wrong please let me know.  In addition this how-to shows you how to setup this same VSFTP server as a FTP YUM repository.

Continue reading

Share Button

Centos – Create an FTP yum repository with out user authentication for your private Network

Create a YUM repo that retrieves files from an VSFTP server. This tutorial is closely tied to the tutorial that shows how to create a YUM repository using Apache, which is located here. In this how to the same repository directory will be used that Apache is using but we will also make it available via VSFTP. Reason being is that there is no need to have double copies of the same files on the same server.

Setup your YUM Repo Server

1) Install VSFTP

yum install vsftpd

2) Create your YUM directory 

mkdir /var/ftp/ftp_repo

3) Mount the contents of your YUM repository that Apache servers to this newly directory

mount --bind /storage/Centos06/centos/ /var/ftp/ftp_repo/

4) Allow user root to access the ftp directory by uncommenting out the user root

vi /etc/vsftpd/user_list

5) Start your VSFTPd Service

service vsftpd start

Make sure that your firewall will allow FTP connections.

Setup your client machine

1) Create your new repo file

vi /etc/yum.repos.d/ftp.repo

2) Add the following entries

[ftp_repo]
name=ftp_repo
baseurl=ftp://192.168.1.26/ftp_repo
enabled=1

 

Run yum repolist in order to see YUM sees your new repo. Then run yum update in order to make sure it can login to the FTP server.

Share Button

BASH – Script that reports failed SSH connections

It will scan for servers in the network you specified and detect which servers have the SSH port open thus avoiding any non SSH running servers such as Windows (saves a huge amount of time).  In other words you can only SSH to a server by actually typing your password.

The script assumes that ssh passwordless access is not setup. In order for this to work you will need to install the sshpass utility found in the EPEL yum repository and also have nmap installed.  The script will only report on which servers a specific username failed to connect.

 

>SSH_failure
ADMINLOGIN="gmastrokostas"
ADMINPASS="SomePassword"
#It is useless to scan host ".1" and ".255". In fact it is borderline dangerous to scan 255 because the router will broadcast the command on all servers which will lead to a lot of traffic 
nmap_network=`nmap -n -P0 -p22 192.168.1.2-254 | grep Interesting | awk '{print $4}' | awk -F: '{print $1}'`

for loop in $nmap_network;
do
/usr/bin/sshpass -p $ADMINPASS ssh -oStrictHostKeyChecking=no -oCheckHostIP=no -t $ADMINLOGIN@$loop exit;
if [[ $? -gt 0 ]];
then
echo "Failed to connecit to server "$loop"" >> SSH_failure
else
echo "Success on $loop";
fi
done
echo "Here are the servers user name $ADMINLOGIN cannot login"
for loop in `awk '{print $6}' SSH_failure`; do nslookup $loop | grep name | awk '{print$4}'; done;
Share Button

CentOS – KickStart File command

Below is a simple example of the KickStart command that can be used to do an install via a Kickstart file that is located on an accessible Web Site.

linux ks=http://172.168.1.xx/ks/KickStartFile.cfg "enter_the_appropriate_cfg_file" ksdev=eth0 ip="IP_of_the_server" netmask=255.255.255.0 DNS="DNS machine is pointing to"

EXAMPLE: The command below will do an install on the server the command will run on:

linux ks=http://172.168.1.xx/ks/KickStartFile.cfg ksdev=eth0 ip=192.168.11.02 netmask=255.255.255.0 DNS=192.168.1.20
Share Button

BASH – Generic Linux report scripts.

These scripts are generic reporting scripts that provide general information regarding CPU-Filesystem-RAM usage, uptime, detection if the server is a VMware server or not, Version of Operating System, active TCP sockets and more. These scripts can entered in a for loop and run on multiple servers in order to get an overall picture of the servers.

Continue reading

Share Button

BASH – Script that distinguishes between a Database Server and a Web Server and does service checks.

The script can be used in a for loop. It generates an Error Alarm only when a critical condition is at hand. These specific conditions are as follows. The script can detect if the server is running Apache or PostgreSQL. So if for example it sees that Apache is not installed it will not do a check for the Apache process. It will move on to do a check for PostgreSQL and perform the same check as mentioned above. In other words the script is not blindly checking for processes.

If Apache is down.
If PostgreSQL is down.
If CPU load exceeds normal levels
If the root partition has reached 90% usage
If /storage (other specific directory of your choosing) has reached 90% usage.

Continue reading

Share Button

Python – Reference point script for services and default ports.

This is really my first Python Script. It is meant more as an exersice for me to learn Python. It uses a dictionary that stores services and default ports being used. This is really a useless script 🙂

Continue reading

Share Button