Configuration & Hooks
While SKM is designed to operate seamlessly out of the box with zero configuration, power users often need custom storage locations and automated workflows. This page details how to configure global paths and utilize SKM's powerful Hook mechanism.
Global Options and Custom Paths
By default, SKM hardcodes its operations against two specific directories:
- Store Path (
~/.skm): The isolated vault where all your key aliases live. - SSH Path (
~/.ssh): The live directory where the OpenSSH client expects to find active keys.
You can override these paths temporarily for a single command using global flags:
skm --store-path /mnt/usb/.skm --ssh-path /home/user/.custom-ssh ls
Setting a Persistent Custom Store Path
A common security practice is to store SSH keys on an encrypted removable drive, or within a synchronized, encrypted cloud folder.
You can tell SKM to persistently use a custom vault directory by exporting the SKM_STORE_PATH environment variable in your shell profile (~/.bashrc, ~/.zshrc, or ~/.profile).
# Instruct SKM to use a secure, encrypted volume for key storage
export SKM_STORE_PATH="/Volumes/SecureUSB/.skm"
Once this is sourced, running skm init or skm create will operate entirely within /Volumes/SecureUSB/.skm.
Warning: If you place your store path on a removable drive, ensure the drive is mounted before running skm use. If the drive is disconnected, the symlinks in ~/.ssh will become broken (dangling).
The Hook Mechanism
Switching SSH keys is rarely an isolated task. Usually, when your SSH identity changes, your surrounding development context needs to change as well.
SKM's Hook mechanism allows you to drop an executable script into any alias directory. Whenever you run skm use <alias>, SKM will automatically execute that script after successfully swapping the SSH symlinks.
Step-by-Step: Creating a Git Config Hook
The most common use case for hooks is dynamically updating your global Git author information to match the active SSH key.
-
Navigate to the target alias directory:
cd ~/.skm/work-profile -
Create the hook file: The file must be named exactly
hook(no extension).touch hook -
Write the execution script: Open the file in a text editor and add standard shell commands. SKM passes the activated alias name as the first positional argument (
$1), which you can use for dynamic logic.#!/bin/bash # ~/.skm/work-profile/hook # Update Git globals to the corporate identity git config --global user.name "Jane Doe" git config --global user.email "[email protected]" # Print a helpful confirmation message echo "✅ Git configuration updated for Enterprise context (Alias: $1)" -
Make the hook executable (Critical Step): If the file lacks execution permissions, SKM will silently ignore it.
chmod +x hook
Example: AWS Profile Switching Hook
Hooks aren't limited to Git. You can orchestrate complex environment changes. For example, syncing your AWS CLI profile with your SSH identity:
#!/bin/bash
# ~/.skm/aws-prod/hook
# Point AWS CLI to the production profile
export AWS_PROFILE="production-admin"
# Notify a local logging service or desktop notification system
osascript -e 'display notification "SSH and AWS profiles swapped to Production!" with title "SKM Hook"'
Troubleshooting Hooks
If your hook isn't running after typing skm use <alias>, verify the following:
- Naming: The file must be named exactly
hook, nothook.shorHook. - Location: It must be placed directly inside the specific alias directory (e.g.,
~/.skm/myalias/hook). - Permissions: You must run
chmod +x hook. You can verify this by runningls -la ~/.skm/<alias>/hook; the permissions should showrwxr-xr-x. - Shebang: Ensure the first line of your script defines the interpreter (e.g.,
#!/bin/bashor#!/usr/bin/env python3).