Skip to main content

SSH Profile

PyPI version

Network-aware SSH config profile selector.

ssh-profile answers one question -- which profile applies on the network this machine is on right now? -- so your ~/.ssh/config can pick the SSH options that fit. One shared ~/.ssh/config + ssh-profile.toml pair then works across all your machines and networks, instead of per-machine configs that drift.

Features

  • Network-aware profile selection -- detect which profile applies on the current network and use it as an ssh_config Match exec predicate.
  • Four detection tiers, evaluated as a first-match-wins cascade: hostname, cidr (wired IPv4), gateway_mac, and ssid.
  • Safe by design -- predicate mode is silent on stdout; lenient runtime loading fails toward the conservative unknown profile; a broken ssh-profile fails the connection loudly rather than misconnecting.
  • Validation built in -- --check-config checks the profile data file and your ~/.ssh/config references; --check-tools checks for the existence of the ip/ping/iw tools.
  • Fast -- a short-TTL cache speeds up the burst of ssh-profile invocations generated by an ssh connection; the initial network detection is shared across the burst.
  • One shared config -- a common ~/.ssh/config + ssh-profile.toml pair can be used (sync'd) across machines avoiding per-machine drift.

Installation

ssh-profile is a CLI tool hosted on PyPI, so a common installation method is to use pipx as follows:

pipx install ssh-profile

Other install methods (plain pip, uv, from source) are covered in the Installation guide.

Quick start

ssh-profile reads its profiles and detection rules from ~/.ssh/ssh-profile.toml. Here is a simple example with two profiles -- one matched by Wi-Fi SSID, the other by a wired IPv4 range:

[profiles]
home       = "Trusted home LAN"
work-wired = "Office, wired"

[[tiers]]
kind  = "ssid"
rules = [{ ssid = "HomeNet", profile = "home" }]

[[tiers]]
kind  = "cidr"
rules = [{ network = "203.0.113.0/24", profile = "work-wired" }]

With that file in place, ssh-profile prints the profile that matches the current machine's network:

$ ssh-profile
home

Use the profile name in an ssh_config Match exec predicate to select SSH host options by profile (excerpted -- see the Configuration guide for the full pattern):

Match originalhost myserver exec "ssh-profile home"
    HostName 10.0.0.50
    User me

Match originalhost myserver exec "ssh-profile work-wired"
    HostName myserver.internal
    ProxyJump bastion.work
    User me.work

Validate the profile data file and ~/.ssh/config references after each edit:

ssh-profile --check-config

Project links

License

MIT. Created in 2026 by Scott Karlin.

Release files for ssh-profile 0.2.0

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

Source distribution (sdist)

Source distribution for ssh-profile 0.2.0
File Size Uploaded
ssh_profile-0.2.0.tar.gz 35.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ssh-profile 0.2.0
File Interpreter ABI Platform
ssh_profile-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 58.4 kB

Release files / ssh_profile-0.2.0.tar.gz

Download URL ssh_profile-0.2.0.tar.gz
Size 35.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9d0b44757e3fec3cd9cac2996bbeee9b381e0a67e64543d309539d7bb9d831f9
BLAKE2b-256 checksum
How to use checksums
da5e38e6dd2dc6cc8717ca4d8bf36e54998a587a3fb1771accf6630cad1670ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ssh_profile-0.2.0-py3-none-any.whl

Download URL ssh_profile-0.2.0-py3-none-any.whl
Size 23.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
184ce366635e799901307c2238bcc7a5baa283736967c8d4defcb77c20d23fdc
BLAKE2b-256 checksum
How to use checksums
c53cb5b1808208877e1ebd9b37f243b36aa0e09008235660d2f45017d151d9d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

0.0.1

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