Append SSH Key to Remote Server
I first must apologise for not blogging for ages, I have no excuse other than laziness!
I recently created a new server at home and install Ubuntu 9.10 Server on it. As a consequence all the SSH keys I used to access my old server were lost and I needed to add them back again….one at a time from each machine I use to access it.
Although this does not seem a big deal, the method I was using previously was as follows:-
cat ~/.ssh/id_rsa.pub | ssh <user>@<host> 'dd of=.ssh/authorized_keys oflag=append conv=notrunc'
Although this worked fine, I was catching up on my Linux reading and in Linux Journal #184 (August 2009) another reader Mark K. Zanfardino wrote in withe following more simplified command which works great on Ubuntu:-
ssh-copy-id -i ~/.ssh/id_rsa.pub <user>@<host>
This is not only easier to remember, it also checks that the key being added doesn’t already exist on the server! Brilliant!