ramfza
Last Updated: February 25, 2016
·
1.334K
· jimeh
C48498c82bfaf0c6c8843ba85e3cd598

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
}
Say Thanks
Respond
Filed Under