171

I am having trouble trying to install ssh-copy-id on my Mac. I have tried to follow https://github.com/beautifulcode/ssh-copy-id-for-OSX but every time I run ssh-copy-id it gives me errors. Any ideas on how to get ssh-copy-id to install?

nwinkler
  • 52,665
  • 21
  • 154
  • 168
Technic1an
  • 2,697
  • 5
  • 20
  • 22

5 Answers5

346

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 
nwinkler
  • 52,665
  • 21
  • 154
  • 168
  • First gave me errors, but it turned out my brew library was a bit overdue for a refresh. Running `brew update` and then installing again solved the problem. – LapplandsCohan Sep 29 '16 at 18:30
27

MacPorts version: sudo port install openssh +ssh-copy-id

Victor Sergienko
  • 13,115
  • 3
  • 57
  • 91
6

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
Ryan
  • 4,594
  • 1
  • 32
  • 35
6

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

Kara
  • 6,115
  • 16
  • 50
  • 57
Sherif O.
  • 506
  • 4
  • 15
  • 1
    You left out the `chmod 700` from your linked site. You could instead use: `ssh USER@HOST 'umask 077 && mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys'` – jrw32982 Jun 01 '20 at 20:46
  • Both merged together is: `cat ~/.ssh/id_rsa_name.pub | ssh @192.168.1.X "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys"` - it works for my old mac - `El Capitan` – Manuel Jordan Oct 01 '22 at 15:41
0

install homebrew then $ brew install ssh-copy-id

vikrantt
  • 2,537
  • 1
  • 13
  • 7