forked from gsauthof/dracut-sshd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixup /etc/shadow to allow ssh pubkey login with disabled password
SSH pubkey login while the password is disabled is common on normal systems. That normally shows up in /etc/shadow as '^root:!:' Both '!' and '*' are invalid hashes denoting the password is disabled but sshd with "UsePAM no" differently interprets where '!' disallows logins despite a valid ssh pubkey. If you installed and manually enabled dracut-sshd networking you surely did not intend for it to deny ssh pubkey authentication. 99sshd-shadow-fixup runs after 99base had copied the /etc/shadow entry replacing the '!' character with '*' thereby allowing SSH pubkey login to work as intended. Fixes: gsauthof#19 Signed-off-by: Warren Togami <wtogami@gmail.com>
- Loading branch information
Showing
2 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
# 2023, Warren Togami <wtogami@gmail.com> | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
# called by dracut | ||
check() { | ||
require_binaries sshd || return 1 | ||
# 0 enables by default, 255 only on request | ||
return 0 | ||
} | ||
|
||
# called by dracut | ||
depends() { | ||
return 0 | ||
} | ||
|
||
# called by dracut | ||
install() { | ||
# /etc/shadow "root:!:" allows for ssh pubkey logins on a normal system. | ||
# dracut-sshd "UsePAM no" is incompatible with a '!'. Fixup to '*' which allows ssh pubkey login to work as intended. | ||
grep '^root:!:' "$initdir/etc/shadow" -q && sed -i -e 's/^root:!:/root:*:/' "$initdir/etc/shadow" | ||
|
||
return 0 | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters