/mandos/release

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

« back to all changes in this revision

Viewing changes to mandos-keygen

  • Committer: Teddy Hogeborn
  • Date: 2017-02-23 20:20:34 UTC
  • mfrom: (237.7.447 trunk)
  • Revision ID: teddy@recompile.se-20170223202034-0820bcq0k7d1j9kf
Merge from trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
3
3
# Mandos key generator - create a new OpenPGP key for a Mandos client
4
4
5
 
# Copyright © 2008-2014 Teddy Hogeborn
6
 
# Copyright © 2008-2014 Björn Påhlsson
 
5
# Copyright © 2008-2017 Teddy Hogeborn
 
6
# Copyright © 2008-2017 Björn Påhlsson
7
7
8
8
# This program is free software: you can redistribute it and/or modify
9
9
# it under the terms of the GNU General Public License as published by
21
21
# Contact the authors at <mandos@recompile.se>.
22
22
23
23
 
24
 
VERSION="1.6.9"
 
24
VERSION="1.7.14"
25
25
 
26
26
KEYDIR="/etc/keys/mandos"
27
27
KEYTYPE=RSA
218
218
        #Handle: <no-spaces>
219
219
        #%pubring pubring.gpg
220
220
        #%secring secring.gpg
 
221
        %no-protection
221
222
        %commit
222
223
        EOF
223
224
    
285
286
    esac
286
287
    
287
288
    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 }"
 
289
        for ssh_keytype in ecdsa-sha2-nistp256 ed25519 rsa; do
 
290
            set +e
 
291
            ssh_fingerprint="`ssh-keyscan -t $ssh_keytype localhost 2>/dev/null`"
 
292
            set -e
 
293
            if [ $? -ne 0 ]; then
 
294
                ssh_fingerprint=""
 
295
                continue
 
296
            fi
 
297
            if [ -n "$ssh_fingerprint" ]; then
 
298
                ssh_fingerprint="${ssh_fingerprint#localhost }"
 
299
                break
 
300
            fi
 
301
        done
295
302
    fi
296
303
    
297
304
    # Import key into temporary key rings
318
325
            cat "$PASSFILE"
319
326
        else
320
327
            tty --quiet && stty -echo
321
 
            echo -n "Enter passphrase: " >&2
322
 
            read first
 
328
            echo -n "Enter passphrase: " >/dev/tty
 
329
            read -r first
323
330
            tty --quiet && echo >&2
324
 
            echo -n "Repeat passphrase: " >&2
325
 
            read second
 
331
            echo -n "Repeat passphrase: " >/dev/tty
 
332
            read -r second
326
333
            if tty --quiet; then
327
334
                echo >&2
328
335
                stty echo
363
370
            }
364
371
        }' < "$SECFILE"
365
372
    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"'
 
373
        echo 'checker = ssh-keyscan -t '"$ssh_keytype"' %%(host)s 2>/dev/null | grep --fixed-strings --line-regexp --quiet --regexp=%%(host)s" %(ssh_fingerprint)s"'
367
374
        echo "ssh_fingerprint = ${ssh_fingerprint}"
368
375
    fi
369
376
fi