Making Pageant automatically load keys on startup

So I have a few private keys I generated for Public-Key SSH authentication. In Windows I manage SSH keys with Pageant – an SSH authentication agent for PuTTY. PuTTY is an awesome SSH/Telnet client for Windows that also comes with a suite of helper utilities like key generator and agent.

My work week starts like this: I log into my Windows workstation, open Pageant and load my keys one after another. Since the keys are encrypted I have to enter a password for each key. Once the keys are in memory I can securely log into multitude of Linux servers and routers (that have the public key) without enduring their login prompt each time. Pretty nice, but there is still some room for improvement.

I would like Pageant to start on boot/login and automatically load my keys. Pageant can load one or more private keys when it starts up if you provide them on the Pageant command line. The simplest way to do this in Windows is to create a specially crafted shortcut inside the Startup folder (Start -> Programs -> Startup):

  1. Go to Start menu, then “Programs”, right click on the Startup folder and choose “Open”
  2. Right-click inside the folder and select “New”, then “Shortcut”
  3. Browse to your PuTTY installation, for example “C:\Program Files\PuTTY” and select “pageant.exe”
  4. Name the shortcut whatever you want
  5. Right-click the newly created shortcut and select “Properties”

You should see something like this:

If all you have is one private key, simply append its full path to your “Target” field like so:

Target: “C:\Program Files\PuTTY\pageant.exe” C:\Path\to\myKeys\MyKey.ppk

Not bad, but with multiple keys the line becomes rather long. It also feels rather silly to specify the same path multiple times when all keys are stored in the same folder like this:

Target: “C:\Program Files\PuTTY\pageant.exe” C:\Documents and Settings\myaccount\My Documents\myKeys\key1.ppk C:\Documents and Settings\myaccount\My Documents\myKeys\key2.ppk C:\Documents and Settings\myaccount\My Documents\myKeys\key3.ppk

This is where the field “Start in” can help. By changing it we can tell Pageant to start in the folder containing our keys and load them by file name:

Target: “C:\Program Files\PuTTY\Pageant.exe” key1.ppk key2.ppk key3.ppk

Start in: “C:\Documents and Settings\myaccount\My Documents\myKeys”

Much better! This single shortcut will start Pageant and load the keys. If the keys are stored encrypted, Pageant will request the passphrases on startup, otherwise they’ll be loaded without any prompts. If Pageant is already running, this will simply load the keys.

 

Source: https://blog.shvetsov.com/

Folder share permissions script

I created this script just to make my life a little bit easier.

Requirements:

Either run this script as administrator or create a shortcut to this script, set it to run as admin.

 

@echo off
color 0a
goto check_Permissions
:check_Permissions
echo Administrative permissions required. Detecting permissions…

net session >nul 2>&1
if %errorLevel% == 0 (
echo Success: Administrative permissions confirmed.
goto start
) else (
color 0c
echo Failure: Current permissions inadequate. Please run as administrator. Recommend creating shortcut and setting it to run as admin.
goto end
)

pause >nul

:start
echo ===============
echo Folder Share Script
echo ===============
set /p arpath=Copy folder path into this window and press enter:
for %%A in (%arpath%) do set filename=%%~nxA
net share “%filename%”=”%arpath%” /GRANT:EVERYONE,FULL /CACHE:NONE
cls
echo Folder shared successfully. Press any key to exit
:end
pause > nul

NIC Switch Script

This script enables you to enable and disable NIC’s as you wish. Make sure to run an elevated command prompt.

:::::::::::::::::::::::::::::::::::::::::
:: Automatically check & get admin rights
:::::::::::::::::::::::::::::::::::::::::
@echo off

ECHO.
ECHO =============================
ECHO Running Admin shell
ECHO =============================

:checkPrivileges
NET FILE 1>NUL 2>NUL
if ‘%errorlevel%’ == ‘0’ ( goto gotPrivileges ) else ( goto getPrivileges )

:getPrivileges
if ‘%1’==’ELEV’ (shift & goto gotPrivileges)
ECHO.
ECHO **************************************
ECHO Invoking UAC for Privilege Escalation
ECHO **************************************

setlocal DisableDelayedExpansion
set “batchPath=%~0”
setlocal EnableDelayedExpansion
ECHO Set UAC = CreateObject^(“Shell.Application”^) > “%temp%\OEgetPrivileges.vbs”
ECHO UAC.ShellExecute “!batchPath!”, “ELEV”, “”, “runas”, 1 >> “%temp%\OEgetPrivileges.vbs”
“%temp%\OEgetPrivileges.vbs”
exit /B

:gotPrivileges
::::::::::::::::::::::::::::
:START
::::::::::::::::::::::::::::
setlocal & pushd .

REM Run shell as admin (example) – put here code as you like
cls
goto Choices

REM use this command to determine what the adapter index number is
REM wmic nic get name, index

:Top
choice /c:123
If ERRORLEVEL == 3 goto NICIndex
If ERRORLEVEL == 2 goto Disable_LAN
If ERRORLEVEL == 1 goto Enable_LAN
goto EOF

:1
:Enable_LAN
wmic path win32_networkadapter where index=14 call enable

goto :EOF

:2
:Disable_LAN
wmic path win32_networkadapter where index=14 call disable
goto :EOF

:3
:NICIndex
cls
wmic nic get name, index
pause
goto :EOF

:Choices
echo 1 Enable LAN
echo 2 Disable LAN
echo 3 Get NIC index
goto Top

:EOF

 

How to run Outlook 2007/2010/2013/2016 Rules from a button

To be able to run a single (or all) rules from a single button instead of having to use the outlook rules dialogue box, the following code should help:


First, go into the VB Editor,  Tools -> Macro’s > Visual Basic Editor (or press ALT-F11)

Assuming you don’t already have any modules in here.  Press Insert -> Module

You will be presented with a new window waiting for code, paste this in for all rules:


Sub RunAllInboxRules()
Dim st As Outlook.Store
Dim myRules As Outlook.Rules
Dim rl As Outlook.Rule
Dim count As Integer
Dim ruleList As String
‘On Error Resume Next’ get default store (where rules live)
Set st = Application.Session.DefaultStore
‘ get rules
Set myRules = st.GetRules

‘ iterate all the rules
For Each rl In myRules
‘ determine if it’s an Inbox rule
If rl.RuleType = olRuleReceive Then
‘ if so, run it
rl.Execute ShowProgress:=True
count = count + 1
ruleList = ruleList & vbCrLf & rl.Name
End If
Next

‘ tell the user what you did
ruleList = “These rules were executed against the Inbox: ” & vbCrLf & ruleList
MsgBox ruleList, vbInformation, “Macro: RunAllInboxRules”

Set rl = Nothing
Set st = Nothing
Set myRules = Nothing
End Sub


The below is for a single rule, don’t forget to change rule name:


Sub RunAllInboxRules()
Dim st As Outlook.Store
Dim myRules As Outlook.Rules
Dim rl As Outlook.Rule
Dim runrule As String
dim rulename as string

Rulename = “*****name of rule*****”

Set st = Application.Session.DefaultStore

Set myRules = st.GetRules

For Each rl In myRules

If rl.RuleType = olRuleReceive Then

If rl.Name = rulename Then
rl.Execute ShowProgress:=True
runrule = rl.Name

End If
End If
Next

ruleList = “This rule was executed against the Inbox:” & vbCrLf & runrule
MsgBox ruleList, vbInformation, “Macro: RunAllInboxRules”

Set rl = Nothing
Set st = Nothing
Set myRules = Nothing
End Sub

Source: http://pyrocam.com/

Script for updating coretemp

This script assumes that wget is installed in %SYSTEMROOT%.

The purpose of this script is to quickly download, install (with default settings), and update coretemp to the latest version on a machine

 

wget http://www.alcpu.com/CoreTemp/Core-Temp-setup.exe -O %UserProfile%\Desktop\coretemp.exe

%UserProfile%\Desktop\coretemp.exe /sp /silent /closeapplications

START C:\”Program Files”\”Core Temp”\”Core Temp.exe”

del %UserProfile%\Desktop\coretemp.exe

exit

SBS MSSQL$SBSMONITORING 1105 Event Error SQL

You recieve the following error in EventViewer with regards to “MSSQL$SBSMONITORING”, Event ID: 1105

Description:
Could not allocate space for object ‘dbo.EventLog’.’PK_EventLog’ in database ‘SBSMonitoring’ because the ‘PRIMARY’ filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup.
This is generally related to the size of the the database (Exceeds 4GB) Continue reading

Batch script – Remove HP Bloatware

I’ve been getting rather annoyed at having to uninstall the HP crapware that gets put onto client machines, so I’ve written a batch file to remove them all.

It’s not 100% ready yet, you still need to manually run the batch file as administrator, and go through some of the uninstall programs, however they are all called up for you.

This was based on an HP Pro 3515. Continue reading

Batch script – One-Click Downgrade from IE11, IE10, and IE9 to IE8

This is a script that will downgrade IE11, IE10, and IE9 to IE8.

@echo off
echo Downgrading to IE11 to IE10 – Step 1
FORFILES /P %WINDIR%\servicing\Packages /M Microsoft-Windows-InternetExplorer-*11.*.mum /c “cmd /c echo Uninstalling package @fname && start /w pkgmgr /up:@fname /quiet /norestart” Continue reading