I was quite surprised recently to speak to a few people who still weren't aware of ssh-copy-id
They were still doing something laborious like:
cat ~/.ssh/id_rsa.pub
(copy key to clipboard)
ssh yourbox vi ~/.ssh/authorized_keys
(paste key and save)
chmod 400 ~/.ssh/authorized_keys
Or a one-liner:
Although you still may also need to chmod authorized_keys to ensure it isn't world read/writable depending if 'StrictModes yes' is set in sshd_config
This is where ssh-copy-id comes in use, it transfers and appends your key to the remote host whilst also changing the permissions of the remote user's home, ~/.ssh, and ~/.ssh/authorized_keys to remove group writability.
ssh-copy-id user@yourbox
If you have multiple keys and need to specify a certain key you can use:
ssh-copy-id -i ~/.ssh/amazon.pub user@yourbox
For those of you using OSX whilst ssh / ssh-keygen are included ssh-copy-id isn't, to quickly get it check out this blogpost.
Add new comment