Using ssh-copy-id to Push SSH key to Authorized Keys

f44d3-6a00e551c39e1c88340162fcbcab43970d-piEverywhere I have ever worked we have always used complex scripts to push out id files to enable passwordless authentication from a bastion host. Today I stumbled across ssh-copy-id which is about as easy to use as it gets.

Check out the section below for usage and substitute your servers hostname where you see <yourhost>

# ssh-copy-id -i ~/.ssh/ <yourhost>

You will get output similar to what is shown below.

Now try logging into the machine, with “ssh ‘<yourhost>'”, and check in:


to make sure we haven’t added extra keys that you weren’t expecting.

Checkout the link below for more info

Below is a little wrapper script that I use to make using ssh-copy-id even easier. Please feel free to borrow it for a bit.

[code language=”css”]

echo "Please Enter Server Name :"
read servername
ssh-copy-id -i ~/.ssh/ $servername

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.