Something is wrong.
Instagram token error.

Mitigating Issues with Uptime Reminders by way of MunkiReport

Posted: May 9th, 2018 | Author: | Filed under: Uncategorized | No Comments »

A lot of our users have can go weeks or months without a reboot. Then they write in to ask for support on their slow Mac. Well…. reboot man! How would you feel if you didn’t sleep for a couple days? To mitigate this we’ve leveraged munkireport and google sheets to automate this process. We’ve created a google sheet with three four columns; USER NAME SERIAL NUMBER COMPUTER NAME ASSOCIATED EMAIL. Then we wrote a python script to pull this information in and cross reference it against computer records that report an uptime greater than 7 days. At the end of the script we email all of those users and ask them to please reboot.


# munkireport integration to alerts users of 7 day uptime.
import re
import gspread
from oauth2client.service_account import ServiceAccountCredentials
import sqlite3
conn = sqlite3.connect('db.sqlite')
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText

## use creds to create a client to interact with the Google Drive API
scope = ['']
creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope)
client = gspread.authorize(creds)
# Find a workbook by name and open the first sheet
# Make sure you use the right name here.
sheet ="copiousUsers").sheet1
humanname = sheet.col_values(2)
humanname = filter(None, humanname)
serialnumber = sheet.col_values(3)
serialnumber = filter(None, serialnumber)
emailaddress = sheet.col_values(5)
emailaddress = filter(None, emailaddress)
hostname = sheet.col_values(4)
hostname = filter(None, hostname)

# Now find hosts on the shitlist
c = conn.cursor()
#c.execute('SELECT hostname FROM machine INNER JOIN reportdata ON WHERE reportdata.uptime>604800;')
c.execute('SELECT serial_number FROM reportdata WHERE uptime>604800;')
shitlist = c.fetchall()
# clean up the list and make ascii unicode
newlist = []
for tup in shitlist:
newlist = newlist + [item.encode('ascii','backslashreplace') for item in tup]
# get rid of anything after the first (.)
newlist = [i.split('.', 1)[0] for i in newlist]

# loop the list and search for matches against the googlesheet, get the details of each user and make a list of lists.
userlist = []
for line in serialnumber:
if line in newlist:
indexNumber = (serialnumber.index(line))
x = [user, email, host]

for line in userlist:
## user is line[0] and email is line[1] and the host is line[2]
msg = MIMEMultipart('alternative')
msg['From'] = 'yourEmail'
msg['To'] = line[1]
msg['Subject'] = 'Reboot Reminder, Over 7 Days Uptime Detected'

text = """\
Hello %s,

We have noticed that your computer, %s, has been up for 7 days without a reboot. Please reboot your computer when you can. Having a computer left on for too long without a reboot can lead to memory leaks and overall performance issues.

Best Regards,
Automatic Watchdog
""" % (line[0],line[2])
html = """\

Hello %s,

We have noticed that your computer, %s, has been up for 7 days without a reboot. Please reboot your computer when you can. Having a computer left on for too long without a reboot can lead to memory leaks and overal performance issues.

""" % (line[0],line[2])

part1 = MIMEText(text, 'plain')
part2 = MIMEText(html, 'html')

server = smtplib.SMTP('', 587)
server.login("emailaddress", "password")
text = msg.as_string()

server.sendmail("emailaddress", line[1], text)

Cisco SG200-50 Smart Switch Review

Posted: January 2nd, 2018 | Author: | Filed under: Cisco, Networking | No Comments »

How to Compile Monero Miner xmr-stak for Ubuntu 16.04 LTS

Posted: December 12th, 2017 | Author: | Filed under: CryptoCurrenty, Monero | Tags: , , , , | No Comments »

Monero-MiningI have a couple ethereum mining rigs using AMD GPUs but my partner and I would like to diversify our operation. We wanted a Monero CPU and GPU Miner for AMD cards but couldn’t find a pre-compiled binary.

Get AMDAPPSDK You’ll need to get this into your linux rig somehow and install it.

Next we need to prep the system for the build so run the follow lines of bash.

sudo apt install libmicrohttpd-dev libssl-dev cmake build-essential libhwloc-dev cmake-curses-gui
git clone
cd xmr-stak; mkdir build; cd build

Now we’re ready to configure the compilation. ccmake .. -DCUDA_ENABLE=OFF Change the install path to /usr/local/xmr-stak Press “C” a couple times until you see a “G” option for generate config file.

After this I tried to run make but it errored out saying that was missing so make sure the OpenCL library in /opt is pointing to the right place.

tjadmin@rig05:~/xmr-stak/build$ ls -l /opt/AMDAPPSDK-3.0/lib/x86_64/
/opt/AMDAPPSDK-3.0/lib/x86_64/ -> /usr/lib/
tjadmin@rig05:~/xmr-stak/build$ ls -l /usr/lib/
ls: cannot access '/usr/lib/': No such file or directory


rm /opt/AMDAPPSDK-3.0/lib/x86_64/
ln -s /usr/lib/x86_64-linux-gnu/ /opt/AMDAPPSDK-3.0/lib/x86_64/

After this is done you should be able to make and then make install

Once installed navigate to /usr/local/xmr-stak/bin and run sudo ./xmr-stak

You’ll be navigated through some first-run questions to ask for your pool and wallet address and whether you want to run nicehash.

Migrate DNS Service from old host to new host – Server 5.x & 6.x

Posted: September 10th, 2017 | Author: | Filed under: DNS, Mac OS X, macOS Sierra | No Comments »

1F2F983500000578-3499652-image-a-8_1458344126936It’s so easy.

On your source host simply copy the contents of /Library/Server/named to same directory on the new host. Refresh and don’t forget to change the NS records to point to the new host.


Why you should *never* leave your Mac unattended

Posted: July 13th, 2017 | Author: | Filed under: Mac OS X | No Comments »

insecureRecently I was contracted by a local backpack company to automate changing some settings on a bunch of Mac clients. The three main parts to the script had to; clean the connect to servers window and inject a new server record in to favorites, delete all login items referencing an old file server, and find a specific keychain item, retrieve the password, and inject a new keychain item using the same password. The first two were easy enough but the keychain was interesting. Through a little bit of research I soon found that the security command could do most of what I wanted. If you issued a command like

security find-internet-password -a jordan -s file.server.local -w

It would prompt you to either allow or deny access to the item and then spit the password out on the command line. But wait a minute here, in Keychain if I want to show a password I would need the password to the computer to gain access. Not on the command line though. This was pretty interesting I thought. That means as long as I have access to the console and the machine is logged in I can extract *any* password from the login.keychain that I want.

To take this a step further I made a little bash script that dumps the login.keychain to file using security dump-keychain login.keychain then I parse the data finding all the entries that I can retrieve the password for. The script will prompt the user once for each item that it finds in the keychain and then write all the data out to a csv file in /tmp

Is this a security flaw? Well, the jury’s out on that one. Some people say YES! and some people say no. To me, it’s all just rather interesting. Try it out for yourself and you’ll see why you should never leave your machine unattended again.

Download script here

Oh btw, I am *not* a developer. Amateur scripter at best, this code takes a long time to run. Upwards 10 mins for larger keychains.

Low Power File Server for a Sailboat

Posted: April 6th, 2017 | Author: | Filed under: Linux, Work | No Comments »

mason_43_photoRecently I was lucky enough to be a crew member on a sailboat that was making passage through the Caribbean. The Captain of the vessel, who lived aboard, was speaking to me about data storage and how difficult of an equation it was. Sailboats have very little power available to them when they’re underway as most don’t run their engine which is the only source to power the limited batteries kept onboard. He was thinking about picking up a Drobo-Mini and using SSDs to reduce the amount of draw on his system, however this solution is DAS based and doesn’t allow him access to the data unless he plugs directly into the box which means, you need a computer as well. Which is even more draw on the electrical system.

After a quick think and a look around the Internet I decided that the best way to address this issue would be to use a Raspberry Pi 3, a four port USB hub,  multi-SD card reader, and mdadm, with smb, nfs, and upnp. I’m not going to go into the nitty gritty of how to setup a raspberry pi as there are many tutorials available online already. However I will touch on some performance metrics that I was able to pull.

It’ll be small physically, have very little power draw, each microSD card draws between 66–330 mW during data transfer, at idle 0.2mA. Each bank will be less than 1mA at idle and 1.2W during transfer. Each bank should yield close to 800GB, all together I’ve calculated 3.2TB of data storage at 6-8W. Pretty dope hey?
The issue is cost. Prices in CAD
Raspberry Pi is $60
case and parts $20
USB Hub $26
total: $106 plus tax / shipping
Data Storage
Four card reader $20
200GB microSD card $91
800GB bank total $384 plus tax / shipping
Performance will max out at around 40MB/sec which isn’t great however we’re not looking for performance we’re looking for efficiency.
I welcome comments to this plan below :) My next step to this plan would be to get the Pi to be a wireless access point as well.

Restrict RADIUS usage in Server 5.x

Posted: February 29th, 2016 | Author: | Filed under: Uncategorized | No Comments »

2000px-Circle-withsegments.svgThis is a follow up post to my previous article about how to setup RADIUS on Server 5.x

In my Open Directory user list I have a user called scanner with a password of, you guessed it, scanner. Now I know this isn’t the most secure thing ever but the user only has very limited access. Recently I wanted to implement RADIUS so that the VPN concentrator could authenticate against Open Directory but I certainly don’t want the scanner user to be able to authenticate. Previously I would fire up WorkGroup Manager and build a service access control list, SACL. However with WGM now gone I have to do it on the command line. After some hacking I figured it out.

First, you’ll need to make a group in OD called VPN and put the users you would like to have VPN access in it. Then whip open a terminal and get the GUID of that group.

dscl localhost read /LDAPv3/

You’re looking for the “GeneratedUID” record this somewhere. Next edit the following script and put your GeneratedUID into the line where it says NestedGroups

dscl localhost create /Local/Default/Groups/
dscl localhost create /Local/Default/Groups/ RealName
dscl localhost create /Local/Default/Groups/ passwd "*"
dscl localhost create /Local/Default/Groups/ gid 260
dscl localhost create /Local/Default/Groups/ NestedGroups PASTE_GUID_HERE

Then reboot radius with a serveradmin stop/start radius and you should be good to go!

Make certificates quickly

Posted: February 15th, 2016 | Author: | Filed under: SSL | No Comments »

Now that you have your own Certificate Authority setup from my previous article you’ll want a fast way of whipping up new certs. Never fear for making certs is here. Drop the following code into an executable file and place it into the myCA folder. You’ll be able to make certificates at whim by issuing a command like 3650 01



if [[ $# -lt 3 ]]; then
echo $0: requires FQDN for certificate, valid for X days, two digit serial, please document this
echo example: $0 3650 01
echo place this script into the myCA root folder
exit 1

openssl genrsa -des3 -out $HOSTNAME/$HOSTNAME.key 4096
openssl req -new -key $HOSTNAME/$HOSTNAME.key -out $HOSTNAME/$HOSTNAME.csr
openssl x509 -req -days $DAYS -in $HOSTNAME/$HOSTNAME.csr -CA cert/cert.pem -CAkey key/ca.key.pem -set_serial $SERIAL -out $HOSTNAME/$HOSTNAME.crt
openssl rsa -in $HOSTNAME/$HOSTNAME.key -out $HOSTNAME/$HOSTNAME.key.insecure
exit 0

RADIUS Setup for OS X El Capitan – Server 5.x

Posted: February 15th, 2016 | Author: | Filed under: Open Directory, RADIUS, SSL | 2 Comments »

Quite simple to setup. First paste in the following commands.

radiusconfig -setconfig auth yes
radiusconfig -setconfig auth_badpass yes

Now install an SSL cert/key pair for your host, the built in ones are found in /etc/certificates or you followed my previous article about becoming a certificate authority and you have the certs on hand.

radiusconfig -installcerts /path/to/key /path/to/cert

Now… if you didn’t make your own CA and you’re using the built in Apple Server certs then you’ll have to do some extra magicary. First use pull an ls /etc/certificates and not the key, cert, and chain files for your host.

radiusconfig -installcerts /path/to/key.pem /path/to/cert.pem /path/to/chain.pem
radiusconfig -setcertpassword

The last line is the ‘magic’ that I spoke of earlier.

Finally add some clients

radiusconfig -addclient other

Then start the radius server

serveradmin start radius

When I did this recently I didn’t have a way to test the server so I installed the FreeRadius server via brew.

brew install freeradius-server

And then tested the server by using radtest The binary can be found in the following directory /usr/local/Cellar/freeradius-server/3.0.9/bin

The syntax of the command is as follows:

radtest username password radius-server[:port] nas-port-number secret

Here’s an example:

radtest username password 10 secret

An Access-Accept is a passing grade!

Mac OS X Server 5.x El Capitan SSL Certificate Authority

Posted: February 11th, 2016 | Author: | Filed under: Mac OS X, Mac OS X Server, SSL | 3 Comments »

280px-El_Capitan_2005I use Open Directory a lot, I can’t think of many times when I don’t use it at least once a day in some way whether that be direct or indirect. It’s not the best directory system out there – hell, it’s not even very good but it’s what the fine people at Apple have supplied us with and it’s what I use. Although I have long had a pet peeve with the way OD is built if you just run through the setup wizard. The certificate expires in one year. Almost every time I encounter an OD server in the wild nine times out of ten the certs are a mess. They’re either expired or about to expire and all the services that depend on them are freaking out. The clients are constantly being prompted to accept an invalid cert and OD fail-over tends to stop working. My solution has been to build a certificate authority for all my OD installs and to build my own certs that are valid for ten years, that way I won’t have to worry about them expiring and let’s be honest there’s no Mac server on the planet that’s going to last ten years lol (sense the cynicism yet?)

Create the Root Key

First we’re going to hop into a terminal on any Mac OS X box and navigate to somewhere safe in the file system and build the master key, make sure the password you use for this is kept secret and safe.

cd /some/where/safe/I/dont/care/where
mkdir -p myCA/cert myCA/key
cd myCA
openssl genrsa -aes256 -out key/ca.key.pem 4096
chmod 400 key/ca.key.pem

That OpenSSL command is going to ask you a bunch of questions, answer them to the best way you see fit and for the common name put the organization that you’re building this certificate authority for. Do not put an actual domain. Record what you wrote for Common Name because we’re going to need it later. Whitespaces are allowed. Oh and one more pro tip, make sure the value of the certificate common is unique and can’t be half-matched. For example I made a root cert called “Client Name” but when it came to do deploy the certificate via munki, the check install script found a cert called “Client Name Open Directory” and thus the command matched and wouldn’t deploy the new root cert.

Create the Root Cert

openssl req -key key/ca.key.pem -new -x509 -days 3650 -sha256 -extensions v3_ca -out cert/cert.pem
chmod 444 cert/cert.pem

Now we have two files.

cert/cert.pem – This is your CA’s certificate and can be publicly available and of course world readable. You will need to load this certificate into all the clients in your network.

key/ca.key.pem – This is your CA’s private key. Although it is protected with a passphrase you should restrict access to it, so that only root can read it.

Create the First Server key/cert combo

We can now start creating SSL certificates for our various servers and services. Create a directory named a hostname corresponding to the hostname for the computer or service you are creating the certificate for.

Create the first key

openssl genrsa -aes256 -out hostname/hostname.domainname.key 4096

While answering the questions for this make sure you type in the FQDN for server or service you want to secure into Common Name.

Create the server cert

openssl req -new -key hostname/hostname.domainname.key -out hostname/hostname.domainname.csr

Sign the cert

openssl x509 -req -days 3650 -in hostname/hostname.domainname.csr -CA cert/cert.pem -CAkey key/ca.key.pem -set_serial 01 -out hostname/hostname.domainname.crt

Now before we continue I have to drill into you that it’s imperative that you document these certs as you make them, which hosts they’re deployed on to, and what the serial number is. It will help you in the long run.

Finally we’re going to make a passwordless version of the server key, this is the key that we’ll ultimately use on our server. We need a passwordless key so that the Mac OS X services do not need human intervention when trying to use the certs. Otherwise you’ll have to type the cert password in every time you restart the service.

openssl rsa -in hostname/hostname.domainname.key -out hostname/hostname.domainname.key.insecure
mv hostname/hostname.domainname.key hostname/
mv hostname/hostname.domainname.key.insecure hostname/hostname.domainname.key

Import the CA and Cert

Copy the myCA/cert.pem, hostname/hostname.domainname.key, and hostname/hostname.domainname.crt files to your Mac OS X server. Double click on the myCA/cert.pem, this should open the file with Keychain Access which will ask you which keychain to import the cert to. Select the system keychain and then double click on the entry in Keychain Access and set the trust setting to Always Trust.

Next open and click on Certificates. Click on the gear menu and select Import Certificate Identity. Drag in the hostname/hostname.domainname.key, and hostname/hostname.domainname.crt files, when you do this you should see that the files are signed by the organization that you entered in step one. Finally select the cert from the list of certs in and give it time to switch over.

Finally fire up the wiki service in, whip open your browser of choice and connect to the FQDN that you create the SSL cert for. Remember, if your cert common name doesn’t match the way you address the wiki in the URL bar you will get a hostname mismatch error. You MUST make sure the names match from what you type into the certificate’s common name and how you connect to the wiki.

Root Cert Deployment

So now maybe you want to be able to use this cert with some of your clients right? You can do this a multitude of ways. Such as:

Copy the file to /tmp across your network and run the following command as root

security add-trusted-cert -d -r trustRoot -k "/Library/Keychains/System.keychain" "/tmp/cert.pem"; srm "/tmp/cert.pem"

Or if you’re cool you’ll use some sort of package deployment system. I use munki because it’s not backed by some money hungry corporation. Here’s looking at you Cohen. 😉 To do this I made a new package with Composer dropped my root cert into /tmp and then wrapped then finished the Composer wizard. Import this package into munki using munkiimport and then drop aforementioned command into post-install script.


For extra bonus points it would be cool to see if the root cert is installed before we go pushing this package to all the workstations in the network. To do this I added a little check install script to munki. Note that you have change the -c flag to match whatever you wrote for the root cert common name way back in step one.


security find-certificate -c "Root Cert Common Name" /Library/Keychains/System.keychain

if [ $? != 0 ]; then
exit 0
exit 1

You’ll note that the exit codes are reversed here, it’s because Munki will only install if the check install script exits on 0 which is how our security check command will exit if it finds the cert installed. So we flip the exit code to make munki do our bidding.

At this point you should be feeling like a rock star for the following reasons:

  • You haven’t given Go Daddy any money
  • You’ve successfully built and deployed your own cert authority
  • You won’t have to worry about onboarding new machines with the cert cause you’ve got in munki