Last Updated: February 25, 2016
·
1.529K
· jimeh

Shell function to add your public key to a remote machine via SSH

I ripped this from someone else's dotfiles on GitHub a while back, and added the mkdir -p ~/.ssh part incase the folder doesn't exist on the remote machine.

Think of it as a lightweight, dumber and dependency-free version of ssh-copy-id :)

To use it make sure to change the ~/.ssh/id_dsa.pub to the path of your own public key file.

function authme {
  ssh "$1" 'mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys' \
    < ~/.ssh/id_dsa.pub
}