Add SSH Key to authorized_keys in one line

July 26, 2011

This is a great little one liner, to publish your local SSH key to any server you need to work with in one simple line.

*Note you will be asked to verify your password the first time round.

cat ~/.ssh/id_rsa.pub | ssh root@example.com 'cat - >> ~/.ssh/authorized_keys'

About me

Hello! I'm David Heward, how are you going? I'm a Senior Devops/Build Engineer, specialising in AWS & Cloud Automation. Based in London. Strong 10+ year background in Software development. Have a read of my blog. Have a look at some of my working projects. Contact me at @davehewy or on Linkedin.