i come from linux and i know that for automatize shh logins we can use sshpass.

Looking for the sshpass command on MacOS i get this message:

machine0:~ roberto$ brew search sshpass
We won't add sshpass because it makes it too easy for novice SSH users to
ruin SSH's security.  

So what is an alternative to reproduce the sshpass behavior with minimal effort?

I need sshpass to store multiple ssh sessions in my iTerm profiles:
enter image description here

  • You had two questions in here. This site works better when there is only one question per question. That way, it's easier for other people to find solutions if they have the same problem. I've edited out your second question, but feel free to ask it separately. – nohillside Jul 22 '19 at 17:27
  • Do things like stackoverflow.com/questions/32255660/…, serverfault.com/questions/74158/…, stackoverflow.com/questions/50096/how-to-pass-password-to-scp help? Is there a specific need for logging in with a password or would using a public/private key pair work as well? – nohillside Jul 22 '19 at 17:29
  • Sorry you are right, i was thinking questions was strictly linked but it's bettere asking in 2 different question. Thank you for your edit – Roberto Manfreda Jul 22 '19 at 17:30
  • 1
    I'm trying to cretate different profiles on iterm session to store all my shh accesses... Don't know if it's a good choice or not due to security reasons.. I'll investigate if i can use private public keys... I'll add some example in the question when i'm at home :) – Roberto Manfreda Jul 22 '19 at 17:32
  • 1
    The security hole is the password as seen in your screenshot. To resolve this the standard approach is to use public/private key pairs (which for extra security can be protected by a password as well which can be read from Keychain automatically). – nohillside Jul 23 '19 at 12:39

Even though Homebrew has blacklisted sshpass, you can still install it through third-party formula such as hudochenkov's:

brew install hudochenkov/sshpass/sshpass

There are several things to consider before doing this though:

  • It's a third-party formula which may not be updated as routinely as the brew core, so you could potentially miss out on key security updates.
  • SSHPass has been blocked for a reason, it's bad practice and there's likely to be a solution other than SSHPass - the page for SSHPass even states that:

Most user should use SSH's more secure public key authentiaction instead


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .