Skip to content

Instantly share code, notes, and snippets.

View andrewkroh's full-sized avatar

Andrew Kroh andrewkroh

View GitHub Profile
@andrewkroh
andrewkroh / deduplicate_strings.go
Created March 1, 2016 16:02
Deduplicate a Slice of Strings in Go
// Deduplicate returns a new slice with duplicates values removed.
func Deduplicate(s []string) []string {
if len(s) == 0 {
return s
}
result := []string{}
seen := make(map[string]struct{})
for _, val := range s {
if _, ok := seen[val]; !ok {
@andrewkroh
andrewkroh / beats-logstash-tls.md
Last active August 30, 2023 06:40
Using TLS between Beats and Logstash

Using TLS between Beats and Logstash

Beats to Logstash over TLS

The purpose of this document is to help with configuring and troubleshooting using TLS on the connection between Beats and Logstash.

Configuration

You must configure TLS on both the client and server to make this work. This

@andrewkroh
andrewkroh / install-go.ps1
Last active November 24, 2022 13:13
Install Golang using Powershell
# Installs golang on Windows.
#
# # Run script:
# .\install-go.ps1 -version 1.5.3
#
# # Download and run script:
# $env:GOVERSION = '1.5.3'
# iex ((new-object net.webclient).DownloadString('SCRIPT_URL_HERE'))
Param(
[String]$version,
@andrewkroh
andrewkroh / install-golang1.5.1-solaris.sh
Last active November 20, 2017 13:22
Install Golang 1.5.1 on Solaris
#!/bin/bash -e
function setup_profile() {
profile=$1
cat << 'EOF' >> $profile
export GOROOT=/go1.5.1-solaris
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
[ ! -d "$GOPATH" ] && mkdir $GOPATH
EOF
@andrewkroh
andrewkroh / jar-verify-openssl.sh
Created September 8, 2015 18:55
Jar Verification with OpenSSL
# Print attributes inside of DSA/RSA file:
openssl cms -in ORG.RSA -inform DER -noout -cmsout -print
# Verify the signature:
openssl smime -verify -inform DER -in ORG.RSA -content ORG.SF -noverify
# Print signing chain:
openssl pkcs7 -text -in ORG.RSA -inform DER -print_certs -noout
@andrewkroh
andrewkroh / redhat_6_stig.sh
Created March 5, 2015 13:42
Redhat 6 STIG Examples using OpenSCAP
# Install openscap tool.
sudo yum install openscap-utils
# Generate report based on RedHat's scap-security-guide project (SSG).
# Requires EPEL.
sudo yum install scap-security-guide
oscap xccdf eval --profile stig-rhel6-server-upstream \
--results /tmp/`hostname`-ssg-results.xml \
--report /tmp/`hostname`-ssg-results.html \
--cpe /usr/share/xml/scap/ssg/content/ssg-rhel6-cpe-dictionary.xml \
@andrewkroh
andrewkroh / sshd
Last active April 11, 2017 13:57
Google Authenticator PAM - Vagrant User SSH Exception
#%PAM-1.0
# Skip Google Authenticator for the vagrant user:
auth [success=1 default=ignore] pam_succeed_if.so user = vagrant
auth required pam_google_authenticator.so
auth required pam_unix.so
auth required pam_sepermit.so
auth include password-auth
account required pam_nologin.so
@andrewkroh
andrewkroh / KeyExtractor.java
Created November 13, 2014 23:46
Java Keystore Private Key Extractor
/*
* Copyright 2011 Andrew Kroh
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@andrewkroh
andrewkroh / gist:d5d8acb420fbf54babfc
Created October 2, 2014 17:42
Using local puppet filebucket
puppet filebucket --bucket /var/lib/puppet/clientbucket -l get b52b12f6059f118d2db377b92e8458eb
@andrewkroh
andrewkroh / fstab.pp
Created August 9, 2014 16:55
Configuring /etc/fstab with Puppet Augeas
augeas{ '/etc/fstab - nosuid on /sys':
context => "/files/etc/fstab",
changes => [
"ins opt after /files/etc/fstab/*[file = '/sys']/opt[last()]",
"set *[file = '/sys']/opt[last()] nosuid",
],
onlyif => "match *[file = '/sys']/opt[. = 'nosuid'] size == 0",
}
augeas{ '/etc/fstab - acl on /sys':