Package: lessdisks
Version: 0.5.3cvs.20040906-10
Followup-For: Bug #289759

well, i don't even know perl, but i think i figured this out.

strangely enough, the format of a public dsa key starts with "ssh-dss",
not "ssh-dsa".

patch attached, for better or worse.

still, the last part of each public key (i'm not sure if it is required
or optional) is usually the user and host machine the key was generated
on... but everything after the @ sign disappears with this patch.

for a typical key:

host ssh-rsa AEDFHGsdfhafa..key_gibberish..ASDFGaerDsafhaeRY3= [EMAIL PROTECTED]

ends up like:

host ssh-rsa AEDFHGsdfhafa..key_gibberish..ASDFGaerDsafhaeRY3= root

everything after the @ sign gets disappeared, does perl need to escape
the @ somehow?

hopefully it's still a valid known_hosts file, despite that glitch.

live well,
  vagrant
--- lessdisks-keycopy   2005-01-10 13:47:34.000000000 -0600
+++ lessdisks-keycopy.new       2005-01-10 16:19:20.000000000 -0600
@@ -37,16 +37,18 @@
 
 for type in rsa dsa; do
 
-       pubkey="`cat /etc/ssh/ssh_host_${type}_key.pub | tail -n 1 | awk '{ 
print $1 }'`"
-
+       pubkey="`cat /etc/ssh/ssh_host_${type}_key.pub | tail -n 1`"
+       # rsa public keys begin with ssh-rsa, and dsa keys with ssh-dss ...
+       # grab key type from the key itself.
+       pubkey_type="$(echo "$pubkey" | awk '{print $1}')"
        if [ -n "$pubkey" ]; then
                # Make sure there's at least one line for perl to parse
                echo "# dummy line" >> "$workdir/known_hosts"
 
                for name in xapp disk $thishost; do
                        perl -ni -e "\$n++; \
-                               print \"$type $name $pubkey\n\" if \$n==1; \
-                               print && next unless /^((rsa|dsa)\s$name\s|# 
dummy line)/i;" "$workdir/known_hosts"
+                               print \"$name $pubkey\n\" if \$n==1; \
+                               print && next unless /^($name\s$pubkey_type\s|# 
dummy line)/i;" "$workdir/known_hosts"
                done
        fi
 done

Attachment: signature.asc
Description: Digital signature

Reply via email to