Non-Interactive SSH With sshpass

Provide an SSH password from a script or pipeline.

LinuxsshautomationsecurityLow risk
Run sshpass -p 'password' ssh user@host to log in without a prompt.

01Command

Command
$ sshpass -p 'secret' ssh user@host

02What it does

sshpass feeds a password to ssh's TTY, which is useful in legacy automation where keys or an askpass helper cannot be deployed. Prefer sshpass -f file or -e with an environment variable to avoid exposing the secret in the process list.

03Risk

RiskLow risk
Requirementssudo apt install sshpass
!Warning: Passwords on the command line are visible to other users and land in shell history; use SSH keys whenever possible.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • Debian package: sshpass
    Debian · vendor-doc · 2026-09-20
    Evidence: Debian packages sshpass, which supplies a password to SSH non-interactively.
  • sshpass
    Official project · vendor-doc · 2026-09-20
    Evidence: Debian packages sshpass, which supplies a password to SSH non-interactively.

Last verified: 2026-09-22 · Category: Security & Privacy

06Related solutions