SSH

It’s a bit here, isn’t it. Well, that’s because I’m a bit busy these days. Unfortunately. A bit too focussed on tech as well. But that generates at least some output. Like this one: A script to deploy your public SSH key on a lot of remote hosts.

Making this script cost me a lot. I went through several different approaches to find a solution:

  • in bash

  • in perl

  • in bash with expect

At the end and after I’ve managed it in bash with expect, I figured out that this was a common problem and somebody has written a tool called copy-ssh-id for it, that does most of the stuff.

Very annoying.

So I’ve stripped most of the old script away and ended up with a weird, little script that does the magic in one line.

In order to make it work for you as well, you need some more information, I guess:

  1. To make it work I had to temporarily modify my ~/.ssh/config file. I got a lot of host-verification-errors when running the script and couldn’t deploy a single key until I’ve disabled the host verification for all hosts while running the script.

    Host *
      StrictHostKeyChecking no
    
  2. The format of the host-file you provide with the -l parameter is probably not what you’ll have available.

    You therefore need to adjust the $hostname assignment in the script according to your source-file.

  3. The too ssh-copy-id only uses hostnames. Your source-file therefore should contain the hostnames of the hosts, only the IP addresses will not work.