Skip to content

Instantly share code, notes, and snippets.

@briantissue
briantissue / gist:066587871f3abe3e6b77
Last active August 29, 2015 14:13
Check Your Server Disks---Over 90% Utilization
#!/bin/bash
#For checking disk space on our servers
#Clear Yesterday's Log
#Checking for root brought to you by Brad Arnold
if [ "$(whoami)" != "root" ]; then
echo "Not running as root. Exiting..."
echo "Please use sudo -s then run this script again as root."
@briantissue
briantissue / gist:0925058707641841f18a
Created January 24, 2015 02:30
Ubuntu TFTP Setup for Cisco Devices
# Bash Script for setting up tftpd-hpa for cisco devices
# Run As Root
# Check if root
if [ "$(whoami)" != "root" ]; then
echo "Not running as root. Exiting..."
exit 0
else
echo "Running as root. Good"
fi
@briantissue
briantissue / gist:1c8b15c80d472c41ffa6
Created January 27, 2015 21:23
Migrate Linux UIDs and GIDS to new box excluded system IDs
#!/bin/bash
#This shell script is moving uids and gids to new server without grabbing the system accounts
#The one caveat with this script is confirming the UID start limit and upper limit for your distro
#This can be confirmed by checking the /etc/libuser.conf it is denoted there in RHEL distros
#This script is to be ran from the /tmp directory as denoted in BASE
#This script is valid for 6.5 RHEL and down as is. Change UGIDLIMIT to 1000 for v7.0
#Create directory for migration files
BASE=/tmp
if [ -d ${BASE}/move ]
@briantissue
briantissue / gist:c944e00f4e0888438c87
Last active August 29, 2015 14:14
Use Audit Log To Find Public IP Addresses Hitting RHEL v7.0 Box w/SELINUX
#!/bin/bash
# Daily report of IP addresses that have hit the server
# This script will filter out the private IP addresses
# You could use this script to generate a report for white-lists; or auditing purposes
# Check if root
if [ "$(whoami)" != "root" ]; then
echo "Not running as root. Exiting..."
exit 0
else
@briantissue
briantissue / gist:55151baf5adad45fd6d2
Created March 26, 2015 13:16
Find Users W/User Input
#!/bin/bash
read -p "Enter UserID: " userid
touch find-$userid.txt
for HOST in `cat ../server_list|grep -v ^#`; do echo ${HOST}; ssh ${HOST} "hostname;cat /etc/passwd | grep -i $userid"; echo ""; done >> find-$
for HOST in `cat ../server_list2|grep -v ^#`; do echo ${HOST}; ssh ${HOST} "hostname;cat /etc/passwd |grep -i $userid"; echo ""; done >$
read -p "Press [Enter] key to view the number of servers $userid resides..."
cat find-$userid.txt | grep -i $userid | wc -l
read -p "End of script..."
@briantissue
briantissue / Block Source IP Addresses (UFW)
Created December 22, 2016 17:55
This script allows you to quickly block source IP addresses, say during an attempted attack with Ubuntu's UFW
#!/bin/bash
# Check if root
if [ "$(whoami)" != "root" ]; then
echo "Not running as root. Exiting..."
exit 0
else
echo "Editing and Reviewing UFW Firewall Entries"
fi
sudo ufw status numbered
@briantissue
briantissue / lxc-static-ip.sh
Created May 12, 2017 14:43
Linux Container Static IP address Assignment
#!/bin/bash
# Script by Brian Tissue
# Used to assign static IP addresses to LXC containers
LXCPATH='/var/lib/lxc'
if [ "$(whoami)" != "root" ]; then
echo "Not running as root. I told you that you needed to be root, come on man..."
echo "Please use su -s then run this script again as root."
exit 0
@briantissue
briantissue / getdebs.sh
Last active May 17, 2017 14:28
Ubuntu Air-Gapped Servers Package Retrieval
#!/bin/bash
# Used for Airgapped Ubuntu Servers; downloads package and required dependencies
# Just SCP them over to the server that needs them. Ensure OS/Kernel is the same on both.
# Feel free to comment if you have a suggestion to improve the script
read -p "Please enter the package name you would like to look for: " packagesearch
apt-cache search "$packagesearch"
read -p "Please enter the verified package name you would like to download: " package
@briantissue
briantissue / Favorite PS1 Prompt
Created September 20, 2018 18:54
favorite PS1 Prompt
PS1="\n\[\e[1;30m\][$$:$PPID - \j:\!\[\e[1;30m\]]\[\e[0;36m\] \T \[\e[1;30m\][\[\e[1;34m\]\u@\H\[\e[1;30m\]:\[\e[0;37m\]${SSH_TTY:-o} \[\e[0;32m\]+${SHLVL}\[\e[1;30m\]] \[\e[1;37m\]\w\[\e[0;37m\] \n\$ "
#!/bin/bash
# Program name: monitor-website.sh
# Written by Brian Tissue August 30th 2018
if [ "$(whoami)" != "root" ]; then
echo "Not running as root. Exiting..."
echo "Please use sudo -s then run this script again as root."
exit 0
else
echo "Running as root. Good"