inventory-ssh

module
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2026 License: AGPL-3.0

README

inventory-ssh

inventory-ssh is a lightweight wrapper around the standard ssh client. It reads ansible.cfg and Ansible inventory files from the current directory, resolves the requested host, and then runs SSH with the resolved options. If a host is not found, it can fall back to normal SSH behavior.

Features

  • Works as a drop-in wrapper for ssh
  • Works as a drop-in wrapper for scp
  • Auto-detects the mode from the arguments, or forces it with ssh/scp subcommands
  • Reads ansible.cfg and inventory in the current directory
  • Supports defaults for user, port, and keys
  • Optional "inventory only" mode to disable fallback
  • Debug logging toggle

Requirements

  • A working ssh client (OpenSSH recommended)
  • Ansible inventory files and ansible.cfg in the directory where you run the tool

Install

Binaries and distro packages

See the Releases page on GitHub for prebuilt binaries and packages.

Build from source
just build
# or
go build .

Configuration

Copy the sample config to your XDG config directory and rename it:

cp config.yml.sample "${XDG_CONFIG_HOME:-$HOME/.config}/inventory-ssh.yml"

Key options (see config.yml.sample for the full list):

  • path: inventory file path (default ./hosts)
  • ssh_command: path or name of the ssh binary
  • scp_command: path or name of the scp binary (default scp)
  • inventory_only: if true, do not fall back to plain SSH
  • debug: enable debug logs
  • defaults: default user, port, private_keys, and passwords

Usage

Run it exactly like ssh or scp, but from a directory containing your inventory:

inventory-ssh my-host
inventory-ssh scp file.txt my-server:/tmp

By default the mode is auto-detected: a bare inventory host means ssh, a host:path argument means scp. If the host cannot be resolved, the underlying ssh/scp command runs directly.

Optional: set aliases to transparently use it as ssh and scp:

# $HOME/.bashrc
alias ssh="inventory-ssh"
alias scp="inventory-ssh"

Or force the mode with explicit subcommands:

# $HOME/.bashrc
alias ssh="inventory-ssh ssh"
alias scp="inventory-ssh scp"

Note: inventory-ssh unknownhost 'cmd:token' falls back to plain scp (not ssh) when unknownhost is not in the inventory, because cmd:token looks like an scp host:path argument.

Examples

Connect using inventory resolution:

inventory-ssh app-server-1

Force inventory-only behavior (set in config):

inventory_only: true

Notes

  • If the host is not found and inventory_only is false, inventory-ssh runs the underlying ssh command directly.
  • Ansible is a trademark of Red Hat, Inc. This project is not affiliated with, endorsed by, or sponsored by Red Hat or the Ansible project.

License

See LICENSE.md.

Directories

Path Synopsis
cmd
inventory-ssh command
internal
ssh
tui
Package tui provides terminal output helpers with consistent color formatting.
Package tui provides terminal output helpers with consistent color formatting.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL