Search code examples
sshssh-keys

ssh-copy-id installed through Homebrew errors when trying to copy an SSH key


I installed ssh-copy-id through Homebrew.

When I type ssh-copy-id -i mykey.pub [path to remote] I get the following error:

/usr/local/bin/ssh-copy-id: ERROR: failed to open ID file './mykey': No such file or directory

It appears that it's not finding the key because the regex is cutting off the .pub. What am I doing wrong?


Solution

  • It turns out that ssh-copy-id checks whether there is a valid private key in the same directory as the public key it's uploading.

    I was uploading someone else's SSH key so they could access a server. I don't have their private key on my machine, which is why the error occurred.

    One option is to just manually remove that check from the script, but it's hacking the Homebrew code.

    My solution was to run touch mykey to create a blank file using the filename syntax of the corresponding private key to the public key I was uploading (mykey.pub).