So at work, I log into a lot of test boxes that share a common password (most of the time). Now while the password isn’t too long, I still would prefer to not type it every single time i log in to these boxes. Ohh and the installed OS is always changing (part of our testing) so ssh keys isn’t an option.

So I needed a way to ssh via providing a plaintext password on the cli (or through a variable/file, etc..) that i could throw in my zsh file and call it a day.

Enter sshpass…

sshpass is what seems to be a wrapper that launches ssh and enters in the password you supply it on the command line to ssh for auth. This requires no interaction on your part other than making sure the password is specified either on the command line, in a variable, or in a file in your home dir.

sshpass should be available in your distros repo but if it isn’t, get it on sourceforge.
And for mac users that are too lazy to compile, if you have brew installed:

brew install

because if you try just a “brew install sshpass”, you get an awesome message saying brew will never support something that defeats the whole point of ssh’es secure features. And, they are kinda right…however, use cases can vary.

And then just run it like:

sshpass -p 'epicpassword' ssh [email protected]

More here.

Blog Logo

Mario Loria




Because gets old after a while.

Back to Overview