Non-Interactive SSH With sshpass
Provide an SSH password from a script or pipeline.
Run sshpass -p 'password' ssh user@host to log in without a prompt.
01Command
Command
$ sshpass -p 'secret' ssh user@host02What 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
!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: sshpassEvidence: Debian packages sshpass, which supplies a password to SSH non-interactively.
- sshpassEvidence: Debian packages sshpass, which supplies a password to SSH non-interactively.
Last verified: 2026-09-22 · Category: Security & Privacy
06Related solutions
Create an SSH key pair with ssh-keygen (Ed25519)
Generate a modern Ed25519 public/private key pair in ~/.ssh for authenticating to servers and Git platforms without passwords.
Change file permissions with chmod
Add or remove read, write, and execute permission for the owner, group, or others using symbolic or octal modes.
Allow a port through the firewall with ufw
Add a UFW rule to permit inbound traffic on a TCP or UDP port, such as SSH on port 22.