Skip to main content

opkssh-wrapper

A thin shim that transparently wires opkssh into your normal ssh workflow. Alias it as ssh and forget it's there — the wrapper silently ensures your ephemeral OpenPubKey identity is fresh before every connection, then hands all arguments through to the real ssh unchanged.


How it works

When you run ssh user@host:

  1. The wrapper checks whether a valid, non-expired opkssh ephemeral key exists.
  2. If the key is missing or expired, it calls opkssh login (opens a browser for OIDC authentication).
  3. It prepends -o IdentitiesOnly=yes -i <key_path> to your arguments.
  4. It execs the real ssh binary with your original arguments intact.

Your SSH experience is unchanged. Every flag, host pattern, and ~/.ssh/config option continues to work exactly as before.


Usage

Use it exactly like ssh:

ssh user@host
ssh -p 2222 -A user@host
ssh -J bastion user@internal
git push origin main          # works transparently via GIT_SSH / core.sshCommand
rsync -avz src/ user@host:dst/

If your key has expired and a terminal is available, you will be prompted to authenticate. In non-interactive contexts (CI, rsync, git) the wrapper exits with an error and tells you to run opkssh login first.


Installation

Prerequisites

  • Python 3.10 or later
  • opkssh installed and on $PATH

Install the package

pipx (recommended — keeps the tool isolated):

pipx install opkssh-wrapper

pip (system or virtual environment):

pip install opkssh-wrapper

Standalone binary (no Python required at runtime):

Pre-built binaries may be available on the Releases page. Download, mark executable, and place on your $PATH:

chmod +x opkssh-wrapper
mv opkssh-wrapper ~/.local/bin/

Set up the shell alias

The preferred way to use opkssh-wrapper is to alias ssh to it so that every SSH invocation goes through the wrapper automatically.

Choose the section for your shell below. Add the shown snippet to your shell's startup file, then open a new terminal (or source the file) to activate it.


bash

Add to ~/.bashrc:

alias ssh='opkssh-wrapper'

# Keep tab-completion working on the alias.
# bash-completion defines _ssh; redirect that spec to cover the alias name too.
if declare -F _ssh > /dev/null 2>&1; then
  complete -F _ssh ssh
fi

Note: The complete line above re-binds the _ssh completion function to the alias. If bash-completion loads _ssh lazily (common in many distributions), this line is a no-op on the first shell start but will take effect once _ssh has been loaded for the first time. To force it reliably, load the ssh completion before the complete call:

alias ssh='opkssh-wrapper'
# Eagerly load ssh completions, then apply to the alias
_completion_loader ssh 2>/dev/null || true
if declare -F _ssh > /dev/null 2>&1; then
  complete -F _ssh ssh
fi

zsh

Add to ~/.zshrc:

alias ssh='opkssh-wrapper'

# Tell zsh to use ssh's completion spec for the alias.
# This must appear after compinit has run.
compdef opkssh-wrapper=ssh

If you use a framework such as Oh My Zsh or Prezto, place these lines after the framework is sourced (e.g. after source $ZSH/oh-my-zsh.sh).


fish

Add to ~/.config/fish/config.fish:

alias ssh 'opkssh-wrapper'

Then create a completions file so that typing ssh <Tab> delegates to fish's built-in SSH completions:

mkdir -p ~/.config/fish/completions
cat > ~/.config/fish/completions/opkssh-wrapper.fish <<'EOF'
# Reuse all SSH completions for opkssh-wrapper
complete -c opkssh-wrapper -w ssh
EOF

Because the fish alias command creates a shell function named ssh, fish will automatically use existing ssh completions when you type ssh <Tab>. The completions file above additionally provides completions when you invoke opkssh-wrapper directly.

To persist the alias across sessions:

funcsave ssh

Optional: configuration file

Create ~/.config/opkssh-wrapper/config.toml to override defaults:

# Path to the opkssh binary (default: "opkssh", resolved via $PATH)
opkssh_path = "opkssh"

# Path to the real ssh binary (default: auto-detected, skipping the shim)
# ssh_path = "/usr/bin/ssh"

# Path to the ephemeral private key written by opkssh (default: ~/.ssh/id_ecdsa)
key_path = "~/.ssh/id_ecdsa"

# How many hours a freshly-issued key is considered valid (default: 24)
key_ttl_hours = 24

# Seconds to wait for the key file to appear on disk after login (default: 10)
key_wait_timeout = 10

# Seconds before opkssh login is forcibly killed (default: 120)
login_timeout = 120

# If true, attempt browser login even in non-interactive contexts (default: false)
aggressive_login = false

License

LGPL-3.0

Metadata

Release files for opkssh-wrapper 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opkssh-wrapper 0.1.1
File Size Uploaded
opkssh_wrapper-0.1.1.tar.gz 29.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for opkssh-wrapper 0.1.1
File Interpreter ABI Platform
opkssh_wrapper-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 48.8 kB

Release files / opkssh_wrapper-0.1.1.tar.gz

Download URL opkssh_wrapper-0.1.1.tar.gz
Size 29.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0fd276840d1a5a250ba9f6cf3de453e8c0d599db1aabd331bf517c36774eb41e
BLAKE2b-256 checksum
How to use checksums
ca6c1c61876a78585c3b460a986f79e20acaa5d2d9724c2233d8eda5b06c16bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 22, 2026.

Transparency log

Release files / opkssh_wrapper-0.1.1-py3-none-any.whl

Download URL opkssh_wrapper-0.1.1-py3-none-any.whl
Size 19.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8325d2d072cc9936ed77eedc34758ad93b42dca98044c70175bf3f5410e8944b
BLAKE2b-256 checksum
How to use checksums
303a14393aef039afbc4540773a2ef0ec748a4e759971790ac1ef824582670c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 22, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page