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.

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

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s