There are a number of reasons why the test might fail: The server might not be configured to accept public key authentication. Make sure /etc/ssh/sshd_config on the server contains PubkeyAuthentication yes . Remember to restart the sshd process on the server.
To generate an SSH key, use the ssh-keygen tool that comes as a part of OpenSSH. This tool generates public and private key files stored in the ~/. ssh directory, as shown below. Generating public/private rsa key pair.
You can install it using Homebrew:
brew install ssh-copy-id
If you don't want to use Homebrew, you can use this Mac port:
curl -L https://raw.githubusercontent.com/beautifulcode/ssh-copy-id-for-OSX/master/install.sh | sh
MacPorts version: sudo port install openssh +ssh-copy-id
ssh-copy-id
is installed on macOS by default now.
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.12.4
$ which ssh-copy-id
/usr/bin/ssh-copy-id
The above methods do not work on old Macs. I have a lion OS. use this instead because the ssh-copy-id can not be installed with brew on old PCs due to compiling dependencies errors at ssl.
cat ~/.ssh/id_rsa.pub | ssh user@123.45.56.78 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
credit goes to this site
install homebrew
then $ brew install ssh-copy-id
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With