bryanbocao / awesome-cmd-cheatsheets

Quick search the commands you need.
3 stars 1 forks source link

Cannot ssh-copy-id a public key #9

Closed bryanbocao closed 2 years ago

bryanbocao commented 2 years ago

I only have a new user's public key new_id.pub but not its private key and would like to copy the public key to the server.

ssh-copy-id -i ~/.ssh/new_id.pub <user>@<ip>
/usr/bin/ssh-copy-id: ERROR: failed to open ID file '/Users/<user>/.ssh/new_id': No such file or directory
    (to install the contents of '/Users/<user>/.ssh/new_id.pub' anyway, look at the -f option)
bryanbocao commented 2 years ago

Create a virtual private key with the same name in ~/.ssh

cd ~/.ssh
touch ./new_id

and do that again

ssh-copy-id -i ~/.ssh/new_id.pub <user>@<ip>

Reference1 Reference2