Skip to main content

Network-aware SSH config profile selector

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ssh_profile-0.2.0.tar.gz (35.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ssh_profile-0.2.0-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file ssh_profile-0.2.0.tar.gz.

File metadata

  • Download URL: ssh_profile-0.2.0.tar.gz
  • Upload date:
  • Size: 35.1 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for ssh_profile-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9d0b44757e3fec3cd9cac2996bbeee9b381e0a67e64543d309539d7bb9d831f9
MD5 7f935c82b49229a90c33265f6bc8ee17
BLAKE2b-256 da5e38e6dd2dc6cc8717ca4d8bf36e54998a587a3fb1771accf6630cad1670ec

See more details on using hashes here.

File details

Details for the file ssh_profile-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ssh_profile-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 23.3 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for ssh_profile-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 184ce366635e799901307c2238bcc7a5baa283736967c8d4defcb77c20d23fdc
MD5 1e72927eeb7ef2eb2dbc3dd880d95170
BLAKE2b-256 c53cb5b1808208877e1ebd9b37f243b36aa0e09008235660d2f45017d151d9d7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page