I would like to automate ssh login from my Mac.
It does have a simple solution:
sshpass -p my_password ssh m_username@hostname
But my problem is installing sshpass on my Mac.
There are instructions on how to install sshpass here:
https://gist.github.com/arunoda/7790979
For Mac you will need to install xcode and command line tools then use the unofficial Homewbrew command:
curl -L https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb > sshpass.rb && brew install sshpass.rb && rm sshpass.rb
Error: Calling Non-checksummed download of sshpass formula file from an arbitrary URL is disabled! Use 'brew extract' or 'brew create' and 'brew tap-new' to create a formula file in a tap on GitHub instead.
curl -L https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb > sshpass.rb && brew install sshpass.rb && rm sshpass.rb
Apr 27, 2021 at 9:27
Update 2022: Unfortunately, Aleks Hudochenkov is no longer updating his repo. There are a bunch of other repos on GitHub that purport to contain a Homebrew recipe for sshpass. It's up to you which of them (if any) to trust.
Some years have passed and there is now a proper Homebrew Tap for sshpass
, maintained by Aleks Hudochenkov. To install sshpass
from this tap, run:
brew install hudochenkov/sshpass/sshpass
Tap source
sudo rm -rf /Library/Developer/CommandLineTools
and sudo xcode-select --install
.
This repository has been archived by the owner. It is now read-only.
so I can't request bump its version to latest sshpass :(
Feb 3 at 20:01
Another option in 2020 is this homebrew tap, maintained by esolitos
brew install esolitos/ipa/sshpass
authorized_keys
under home directories and that's why your staged public key was rejected, etc)
Aug 26, 2021 at 21:16
Following worked for me
curl -O -L https://sourceforge.net/projects/sshpass/files/sshpass/1.06/sshpass-1.06.tar.gz && tar xvzf sshpass-1.06.tar.gz
cd sshpass-1.06/
./configure
sudo make install
Solution provided by lukesUbuntu from github works for me:
Just use brew
$ brew install http://git.io/sshpass.rb
Error: Non-checksummed download of sshpass formula file from an arbitrary URL is unsupported!
brew extract` or brew create
and brew tap-new
to create a formula file in a tap on GitHub instead.`
Feb 3 at 20:02
Please follow the steps below to install sshpass
in mac.
curl -O -L https://fossies.org/linux/privat/sshpass-1.06.tar.gz && tar xvzf sshpass-1.06.tar.gz
cd sshpass-1.06
./configure
sudo make install
I just followed the instructions from this article and it helped,
curl -O -L http://downloads.sourceforge.net/project/sshpass/sshpass/1.05/sshpass-1.05.tar.gz && tar xvzf sshpass-1.05.tar.gz
//This creates a directory sshpass-1.05
cd sshpass-1.05
./configure
make
sudo make install
For the simple reason:
Andy-B-MacBook:~ l.admin$ brew install sshpass
Error: No available formula with the name "sshpass"
We won't add sshpass because it makes it too easy for novice SSH users to
ruin SSH's security.
Thus, the answer to do the curl / configure / install worked great for me on Mac.
Just a slight update from the previous answer
curl -O -L https://fossies.org/linux/privat/sshpass-1.09.tar.gz && tar xvzf sshpass-1.09.tar.gz
cd sshpass-1.09/
./configure
sudo make install
This Worked as on OCT 2021
I found that most of the answers listed here are out of date. To install the latest, I ran this and downloaded directly from sourceforge.net, based on other answers here.
curl -L https://sourceforge.net/projects/sshpass/files/latest/download -o sshpass.tar.gz && tar xvzf sshpass.tar.gz
cd sshpass-*
./configure
sudo make install
configure: error: in /Users/ME/sshpass-1.08: configure: error: C compiler cannot create executables See config.log for more details
Mar 15 at 21:45
Aargh, the problem with the outdated links.
Simply go to https://sourceforge.net/projects/sshpass/
Download latest version and then tar xvzf
it and finally cd to the dir where it got unpacked
and install with:
./configure make sudo make install
I suppose this will also work on every OS with supported C sdk installed...
ssh-keygen -b 2048
. It will generate a keypair and store them in~/.ssh.
asid_rsa
(private key) andid_rsa.pub
(public key). Copyid_rsa.pub
to linux in the directory~/.ssh/
and name the fileauthorized_keys
. From here on when you connect to linux you will not need a password. The private/public keypair will be used.id_rsa
file on your local machine and 2)scp
theid_rsa.pub
to the server's corresponding folder as suggested and 3) rename theid_ras.pub
file on the server.