Non-interactive SSH password helper for scripting legacy systems that cannot use key-based authentication.
$brew install sshpass
AI Analysis
sshpass is a small wrapper that feeds a password to ssh and other SSH-based commands when a remote system still requires keyboard-interactive authentication. It is mainly a compatibility tool for legacy hosts where key-based auth is unavailable or cannot be enabled.
What It Enables
- Run ssh, scp, rsync, or other SSH-based commands non-interactively against password-only systems.
- Pass credentials from stdin, a file, an inherited file descriptor, or the
SSHPASSenvironment variable instead of typing at a prompt. - Handle common failure cases such as wrong passwords or unknown host keys through exit codes inside scripts.
Agent Fit
- It fits shell automation cleanly because it wraps existing SSH commands and exits non-interactively once arguments are set.
- Machine-readable output is minimal: there is no JSON mode, so most follow-up logic has to use exit codes plus stderr from ssh or the wrapped command.
- Best used as a narrow legacy-access helper inside a larger workflow, not as a general remote-management CLI.
Caveats
- Password automation is weaker than SSH key-based auth; the man page explicitly recommends public key authentication when possible.
- The
-pflag is the least secure option because other users can inspect process arguments, so stdin, file descriptor, file, or environment-based handoff is safer.