Connect MobaXterm with PyBritive
Overview
MobaXterm has no pre-connect script hook, so the best integration is a macro: it runs a pybritive checkout to write a key file, then launches a saved session (bookmark). The macro runs in a PowerShell window because MobaXterm.exe is only available there.
What you’ll learn:
- Write a MobaXterm macro that checks out a profile with PyBritive
- Launch a bookmarked session with the resulting credentials
Before You Begin
- PyBritive installed and authenticated
- MobaXterm installed on Windows
- A Britive profile whose checkout returns an SSH key, with a
pybritiveprofile alias - A MobaXterm bookmark/session whose name matches the alias
Build the Macro
Check out the key, then launch the session
Run this in a MobaXterm PowerShell window (or any PowerShell window):
pybritive checkout demo_box -s | Out-File -FilePath "c:\Users\Administrator\Downloads\demo_box.pem" -Encoding ASCII
RETURN
& "C:\Program Files (x86)\Mobatek\MobaXterm\MobaXterm.exe" -bookmark "demo_box"
RETURNHere demo_box is both the pybritive profile alias and the MobaXterm bookmark name. The checkout writes the key to a .pem file, then MobaXterm opens the matching bookmark.
Adjust names and paths
Change demo_box, the .pem output path, and the MobaXterm install path to match your environment. Keep the alias and bookmark names identical so the macro stays generic.
Verify
Run the macro. PyBritive checks out the profile, writes the .pem, and MobaXterm launches the session using the just-in-time key.
# confirm the key file was written
Test-Path "c:\Users\Administrator\Downloads\demo_box.pem" # True