Commit 403408f
fix(verify): count all OpenSSH key types + avoid 0\n0 integer-expr error
Step [5/5] External Access Lockout reported "SSH keys: 0\n0 authorized"
and "[: 0\n0: integer expression expected" for users whose authorized_keys
contained a valid key. Two bugs combined:
1. `grep -c '^ssh-' ... || echo 0` — when grep finds zero matches it still
prints "0\n" AND exits 1, so `|| echo 0` appends another "0\n".
Command substitution strips only the final trailing newline, leaving
KEY_COUNT="0\n0". This broke both the rendered output (two lines) and
the subsequent [ "$KEY_COUNT" -le 1 ] comparison (bash's `[` refuses
multi-line strings as integers).
2. The `^ssh-` regex missed ecdsa-sha2-* and sk-* key types, so an ECDSA
or hardware-backed key was counted as zero even when validly present.
Fix:
- Broaden regex to `^(ssh-|ecdsa-|sk-)` to cover all standard OpenSSH
public-key type prefixes.
- Swallow grep's exit-1 on zero matches with `|| :` (no stdout) instead
of `|| echo 0`.
- Pre-check file readability and defensively reset KEY_COUNT to 0 if it
somehow ends up non-numeric, so `[ -le 1 ]` is always comparing a
single digit.
Bumps VERSION to v1.5.8.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent bbe9498 commit 403408f
1 file changed
Lines changed: 23 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
676 | 676 | | |
677 | 677 | | |
678 | 678 | | |
679 | | - | |
680 | | - | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
681 | 701 | | |
682 | 702 | | |
683 | 703 | | |
| |||
0 commit comments