/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos-keygen

  • Committer: Teddy Hogeborn
  • Date: 2014-06-22 02:19:30 UTC
  • Revision ID: teddy@recompile.se-20140622021930-icl7h4cm97blhjml
mandos-keygen: Generate "checker" option to use SSH fingerprints.

To turn this off, use a new "--no-ssh" option to mandos-keygen.

* INSTALL (Mandos Server, Mandos Client): Document new suggested
                                          installation of SSH.
* Makefile (confdir/clients.conf): Use new "--no-ssh" option to
                                   "mandos-keygen".
* debian/control (mandos/Depends): Changed to "fping | ssh-client".
  (mandos-client/Recommends): New; set to "ssh".
* intro.xml (FREQUENTLY ASKED QUESTIONS): Rename and rewrite section
                                          called "Faking ping
                                          replies?" to address new
                                          default behavior.
* mandos-clients.conf.xml (OPTIONS/checker): Briefly discuss new
                                             behavior of
                                             mandos-keygen.
* mandos-keygen: Bug fix: Suppress failure output of "shred" to remove
                 "sec*", since no such files may exist.
 (password mode): Scan for SSH key fingerprints and output as new
                  "checker" and "ssh_fingerprint" options, unless new
                  "--no-ssh" option is given.
* mandos-keygen.xml (SYNOPSIS/--force): Bug fix: Document short form.
  (OPTIONS/--no-ssh): New.
  (SEE ALSO): Add reference "ssh-keyscan(1)".
* plugins.d/mandos-client.xml (SECURITY): Briefly mention the
                                          possibility of using SSH key
                                          fingerprints for checking.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
KEYCOMMENT=""
34
34
KEYEXPIRE=0
35
35
FORCE=no
 
36
SSH=yes
36
37
KEYCOMMENT_ORIG="$KEYCOMMENT"
37
38
mode=keygen
38
39
 
41
42
fi
42
43
 
43
44
# Parse options
44
 
TEMP=`getopt --options vhpF:d:t:l:s:L:n:e:c:x:f \
45
 
    --longoptions version,help,password,passfile:,dir:,type:,length:,subtype:,sublength:,name:,email:,comment:,expire:,force \
 
45
TEMP=`getopt --options vhpF:d:t:l:s:L:n:e:c:x:fS \
 
46
    --longoptions version,help,password,passfile:,dir:,type:,length:,subtype:,sublength:,name:,email:,comment:,expire:,force,no-ssh \
46
47
    --name "$0" -- "$@"`
47
48
 
48
49
help(){
85
86
                        Encrypt a password from FILE using the key in
86
87
                        the key directory.  All options other than
87
88
                        --dir and --name are ignored.
 
89
  -S, --no-ssh          Don't get SSH key or set "checker" option.
88
90
EOF
89
91
}
90
92
 
103
105
        -c|--comment) KEYCOMMENT="$2"; shift 2;;
104
106
        -x|--expire) KEYEXPIRE="$2"; shift 2;;
105
107
        -f|--force) FORCE=yes; shift;;
 
108
        -S|--no-ssh) SSH=no; shift;;
106
109
        -v|--version) echo "$0 $VERSION"; exit;;
107
110
        -h|--help) help; exit;;
108
111
        --) shift; break;;
188
191
trap "
189
192
set +e; \
190
193
test -n \"$SECFILE\" && shred --remove \"$SECFILE\"; \
191
 
shred --remove \"$RINGDIR\"/sec*;
 
194
shred --remove \"$RINGDIR\"/sec* 2>/dev/null;
192
195
test -n \"$BATCHFILE\" && rm --force \"$BATCHFILE\"; \
193
196
rm --recursive --force \"$RINGDIR\";
194
197
tty --quiet && stty echo; \
274
277
fi
275
278
 
276
279
if [ "$mode" = password ]; then
 
280
    
 
281
    # Make SSH be 0 or 1
 
282
    case "$SSH" in
 
283
        [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]) SSH=1;;
 
284
        [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|*) SSH=0;;
 
285
    esac
 
286
    
 
287
    if [ $SSH -eq 1 ]; then
 
288
        set +e
 
289
        ssh_fingerprint="`ssh-keyscan localhost 2>/dev/null`"
 
290
        if [ $? -ne 0 ]; then
 
291
            ssh_fingerprint=""
 
292
        fi
 
293
        set -e
 
294
        ssh_fingerprint="${ssh_fingerprint#localhost }"
 
295
    fi
 
296
    
277
297
    # Import key into temporary key rings
278
298
    gpg --quiet --batch --no-tty --no-options --enable-dsa2 \
279
299
        --homedir "$RINGDIR" --trust-model always --armor \
342
362
                /^[^-]/s/^/    /p
343
363
            }
344
364
        }' < "$SECFILE"
 
365
    if [ -n "$ssh_fingerprint" ]; then
 
366
        echo 'checker = ssh-keyscan %%(host)s 2>/dev/null | grep --fixed-strings --line-regexp --quiet --regexp="%%(host)s %(ssh_fingerprint)s"'
 
367
        echo "ssh_fingerprint = ${ssh_fingerprint}"
 
368
    fi
345
369
fi
346
370
 
347
371
trap - EXIT
352
376
    shred --remove "$SECFILE"
353
377
fi
354
378
# Remove the key rings
355
 
shred --remove "$RINGDIR"/sec*
 
379
shred --remove "$RINGDIR"/sec* 2>/dev/null
356
380
rm --recursive --force "$RINGDIR"