Skip to content

Instantly share code, notes, and snippets.

@gregjhogan
gregjhogan / autossh-tunnel-example.sh
Created August 16, 2017 01:25
autossh tunnel example
# ~/.ssh/config
Host {name}
Hostname {host.domain.com}
User {user-name}
Port 22
LocalForward {src-ip}:{src-port} {dst-ip}:{dst-port}
ServerAliveInterval 30
ServerAliveCountMax 4
# command
@gregjhogan
gregjhogan / ansible-win-10-wsl-config.sh
Last active September 26, 2025 06:41
ansible windows 10 WSL configuration
sudo apt-get -y update
sudo apt-get -y install python
sudo easy_install pip
sudo pip install ansible
sudo pip install "pywinrm>=0.2.2"
# kerberos authentication support
#sudo apt-get install -y python-dev libkrb5-dev krb5-user
#sudo pip install pywinrm[kerberos]
@gregjhogan
gregjhogan / ansible-centos-config.sh
Last active August 29, 2017 03:07
ansible-centos-config.sh
sudo yum -y update
sudo yum -y install python
sudo yum -y install python-devel
sudo easy_install pip
sudo pip install ansible
sudo pip install "pywinrm>=0.2.2"
@gregjhogan
gregjhogan / generate-password.ps1
Created August 29, 2017 21:42
Generate Password
Add-Type -AssemblyName System.Web
[System.Web.Security.Membership]::GeneratePassword(32, 8)
# https://msdn.microsoft.com/en-us/library/system.web.security.membership.generatepassword%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396
@gregjhogan
gregjhogan / wireshark-tls-sni-http-filter
Last active October 20, 2022 00:32
wireshark tls sni and http filter
ssl.handshake.extension.type == "server_name" || http.host
@gregjhogan
gregjhogan / azure-vm-runcommand-nowait.ps1
Created September 14, 2017 17:32
Azure VM runCommand PowerShell script
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$InformationPreference = "Continue"
Login-AzureRmAccount | Out-Null
$subscription = "Visual Studio Enterprise"
Write-Information "selecting subscription: $subscription ..."
Select-AzureRmSubscription -SubscriptionName $subscription | Out-Null
@gregjhogan
gregjhogan / user-cert-generation.sh
Created September 18, 2017 17:52
Generating VPN certificates
# https://jamielinux.com/docs/openssl-certificate-authority/sign-server-and-client-certificates.html
# private key
openssl genrsa -aes256 -out private/user.name.key.pem 4096
# certificate request
openssl req -config openssl.cnf -key private/user.name.key.pem -new -sha256 -out csr/user.name.csr.pem
# sign with intermediate ca
openssl ca -config openssl.cnf -extensions usr_cert -days 375 -notext -md sha256 -in csr/user.name.csr.pem -out certs/user.name.cert.pem
# bundle into pkcs12
openssl pkcs12 -export -out ./pkcs12/user.name.pfx -in certs/user.name.cert.pem -certfile certs/ca-chain.cert.pem -inkey private/user.name.key.pem
@gregjhogan
gregjhogan / azure-vm-outbound-proxy-host-list.txt
Created September 22, 2017 01:37
Azure VM outbound internet proxy host list
(^|.*\.)microsoft\.com
(^|.*\.)windows\.net
(^|.*\.)windowsupdate\.com
(^|.*\.)nsatc\.net
(^|.*\.)msocsp\.com
(^|.*\.)live\.com
(^|.*\.)microsoftonline\.com
(^|.*\.)microsoftonline-p\.com
(^|.*\.)visualstudio\.com
(^|.*\.)azure\.com
@gregjhogan
gregjhogan / always-running-scheduled-task.ps1
Created October 14, 2017 19:10
Windows scheduled task that stays running forever and restarts if it dies
$folder = "C:\folder"
$cmd = "powershell.exe "
$args = "-NoLogo -NonInteractive -WindowStyle Maximized -File script.ps1"
$user = "username-to-run-as"
$trigger = New-ScheduledTaskTrigger -Once -At (Get-Date).Date -RepetitionInterval (New-TimeSpan -Minutes 1)
$action = New-ScheduledTaskAction -WorkingDirectory $folder -Execute $cmd -Argument $args
$settings = New-ScheduledTaskSettingsSet -StartWhenAvailable -MultipleInstances IgnoreNew -RestartInterval (New-TimeSpan -Minutes 1) -RestartCount 999 -ExecutionTimeLimit (New-TimeSpan -Seconds 0)
$principal = New-ScheduledTaskPrincipal -UserId $user -LogonType Interactive
$task = New-ScheduledTask -Principal $principal -Action $action -Settings $settings -Trigger $trigger
@gregjhogan
gregjhogan / macos-setup.sh
Last active November 24, 2017 01:07
macOS setup
#!/bin/bash
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor
brew update
brew tap caskroom/versions
brew install node git bash-completion tmux
brew cask install xquartz docker visual-studio-code google-chrome firefox slack spotify