Skip to content

Instantly share code, notes, and snippets.

View lukebrady's full-sized avatar
Coffee Time

Luke Brady lukebrady

Coffee Time
View GitHub Profile
def ProcessText(pattern, text):
sub_str = ''
patt_obj = {pattern : 0}
for l in text:
sub_str += '{}'.format(l)
if sub_str == pattern:
print('{} : {}'.format(sub_str, patt_obj[pattern]))
patt_obj[pattern] = patt_obj[pattern] + 1
sub_str = ''
elif len(sub_str) > len(pattern):
[VMware.Vim.VirtualMachineGuestOsIdentifier].GetEnumValues()
@lukebrady
lukebrady / install_zfs.sh
Created February 6, 2018 02:59
Automates the installation of ZFS on CentOS 7.
#!/bin/bash
CENTOS_VERSION=$(cat /etc/redhat-release | grep -Eho "[6-9]\.[1-9]"| tr . _)
checkUser () {
if [ $(whoami) != "root" ]; then
echo You must be root.
exit 1
fi
}

Better SSH Authorized Keys Management

A seemingly common problem that people encounter is how to handle all of your users authorized_keys file.

People struggle over management, ensuring that users only have specific keys in the authorized_keys file or even a method for expiring keys. A centralized key management system could help provide all of this functionality with a little scripting.

One piece of functionality overlooked in OpenSSH is the AuthorizedKeysCommand configuration keyword. This configuration allows you to specify a command that will run during login to retrieve a users public key file from a remote source and perform validation just as if the authorized_keys file was local.

Here is an example directory structure for a set of users with SSH public keys that can be shared out via a web server:

@lukebrady
lukebrady / Client.cs
Created July 17, 2017 16:48 — forked from leandrosilva/Client.cs
Asynchronous Client/Server Socket Example with C# (from MSDN library)
// Asynchronous Client Socket Example
// http://msdn.microsoft.com/en-us/library/bew39x2a.aspx
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Text;
// State object for receiving data from remote device.
curl -L https://bootstrap.saltstack.com | sudo sh
#!/bin/bash
if [ $(whoami) != "root" ]; then
echo "You must be root to install mesos."
exit 1
fi
#Change to your mesos installation directory.
mkdir /home/luke/apache/
cd /home/luke/apache/
@lukebrady
lukebrady / PingMonitor.sh
Created March 19, 2016 01:53
Monitor incoming ping requests.
sudo tcpdump -i ethX icmp and icmp[icmptype]=icmp-echo
@lukebrady
lukebrady / Linux Static IP
Created February 2, 2016 20:15
Configure your static IPADDR.
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
@lukebrady
lukebrady / display_outbound.sh
Created February 2, 2016 15:42
Shows your outbound IP in Linux.
dig myip.opendns.com @resolver1.opendns.com +short