Skip to content

Instantly share code, notes, and snippets.

View mkorthof's full-sized avatar
⌨️
cli connoisseur

Marius mkorthof

⌨️
cli connoisseur
View GitHub Profile
@mkorthof
mkorthof / csr.sh
Created December 29, 2017 16:17
Generate certificate request with SAN (needs file.key)
#!/bin/bash
# ./csr.sh [domain] [filename] - generate certificate request (needs file.key)
# set domain and key/csr filename permanently:
DOMAIN="example.com"; FN="example"
# set certificate attributes:
C="AU"; ST="Some-State"; L="City"; O="Internet Widgits Pty Ltd"; OU="Section"
@mkorthof
mkorthof / .screenrc
Created October 25, 2017 12:05
alternative for screen + SSH_AUTH_SOCK
# this needs an alias:
# alias screen='echo "setenv SSH_AUTH_SOCK $SSH_AUTH_SOCK" > $HOME/.ssh/screen; screen -X source $HOME/.ssh/screen; screen'
bind H eval "source $HOME/.ssh/screen" "readbuf $SSH_AUTH_SOCK" 'stuff "export SSH_AUTH_SOCK=$SSH_AUTH_SOCK\n"' "echo 'SSH_AUTH_SOCK set!'"
@mkorthof
mkorthof / vboxsave.bat
Created August 24, 2017 13:49
VirtualBox savestate all running VM's (Windows)
@echo off
:: https://superuser.com/questions/959567/virtualbox-windows-graceful-shutdown-of-guests-on-host-shutdown
SET "LOG=0"
SET "LOGFILE=%~dp0%vboxsave.log"
SET VBoxManage="%ProgramFiles%\Oracle\VirtualBox\VBoxManage.exe"
IF "%~1"=="LOG" ( SET "LOG=1" )
IF EXIST "%LOGFILE%.tmp" ( del %LOGFILE%.tmp )
IF %LOG% EQU 1 ( CALL :msg logging is enabled )
@mkorthof
mkorthof / uptime.cmd
Created August 24, 2017 12:39
windows uptime
@PowerShell -ExecutionPolicy RemoteSigned -Command Invoke-Expression $('$args=@(^&{$args} %*);'+[String]::Join(';',(Get-Content -LiteralPath '%~f0') -notmatch '^^@PowerShell.*EOF$')) & goto :EOF
$d = Get-Date
$upTime = (($d) - ([wmi]'').ConvertToDateTime((Get-WmiObject win32_operatingsystem).LastBootUpTime)).ToString("d' days, 'h\:mm")
$ActiveUsers = @()
foreach($User in (Get-WmiObject Win32_LoggedOnUser).Antecedent) { $ActiveUsers += $User.Substring($User.LastIndexOf('=') + 2, $User.Length - $User.LastIndexOf('=') -3) }
$UserText = "$($ActiveUsers.Count) user"
if ( $ActiveUsers.Count -gt 1 ) { $UserText += "s" }
$TotalProcTime = (Get-Counter "\Processor(_total)\% Processor Time") | foreach {$_.CounterSamples[0].CookedValue}
@mkorthof
mkorthof / sshfp.py
Created March 25, 2017 12:37
ssh fingerprints
#!/usr/bin/env python3
# http://stackoverflow.com/questions/6682816/deriving-an-ssh-fingerprint-from-a-public-key-in-python
import base64
import hashlib
def debug(line, field):
# try: print ("DEBUG: line.strip(): %s\n" % line.strip())
# except Exception as e: print ("ERROR: line.strip(): %s \n" % e)
@mkorthof
mkorthof / sshpk.py
Last active March 24, 2017 23:48
sshpubkeys - shows ssh pubkey details
#!/usr/bin/env python3
# https://github.com/ojarva/python-sshpubkeys
import sys
from sshpubkeys import SSHKey
# example (error: <1024 bits)
#ssh = SSHKey("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAYQCxO38tKAJXIs9ivPxt7AY"
# "dfybgtAR1ow3Qkb9GPQ6wkFHQqcFDe6faKCxH6iDRteo4D8L8B"