rc.d/sshd: Add "showfp" cmd to display host key fingerprint It's customized in many cloud images and it's good to have this in base to be used more widely. MFC: 1 week Sponsored by: The FreeBSD Foundation
Details
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 66529 Build 63412: arc lint + arc unit
Event Timeline
I'm cleaning up small local changes when sorting my git workspace. This patch may need to be improved, but need to get it out my private tree first.
Do you know if there's some canonical reference for emitting the fingerprints to the system console on startup? Searching for -----BEGIN SSH HOST KEY FINGERPRINTS----- turns up lots of examples, but if there is some canonical reference it would be good to include here.
| libexec/rc/rc.d/sshd | ||
|---|---|---|
| 77–84 | I'm not sure this check adds much value; trying to specify an algorithm that doesn't yet exist would be a bug in sshd_showfp, and falling through to the warn below is fine in that case I'd say | |
It's learnt from @cperciva 's ec2 scripts https://github.com/cperciva/ec2-scripts/blob/master/ec2_loghostkey . I skipped the ###... lines but the -----BEGIN... part looks good. The ec2: prefix cloud be useful for certain automation in the clouds. We can have an extension of this work for customizing the format (and even expend to other scripts... that's too far for now.)
Agree wrt. the BEGIN SSH HOST KEY FINGERPRINTS and #####... lines. Happy to get this in and iterate after we see what people think.
I wonder if we should also check for presence of the public key.
| libexec/rc/rc.d/sshd | ||
|---|---|---|
| 77 | ||
| libexec/rc/rc.d/sshd | ||
|---|---|---|
| 77 | Presumably || not &&? Of if ! [ -f ${keyfile}" -a -f "${keyfile}.pub ] | |
This is a good point, indeed its output is fingerprint of the public key so perhaps it's better to just check for the public key file. That's what ec2-script does.
I was thinking that checking the private can make sure the key pair is complete, as from the man page ssh-keygen will find the matching public key file.
| libexec/rc/rc.d/sshd | ||
|---|---|---|
| 78 | I'll leave this for now as it's aligning with sshd_keygen_alg(), and maybe update both places in another commit | |
| 83 | Will update along with sshd_keygen_alg() in another commit. | |
This will be displayed on every dmesg -a by default, just like the AWS images. Is this the desired behavior?
| libexec/rc/rc.d/sshd | ||
|---|---|---|
| 77 | Yes, you are correct. Checking the presence of both files. | |
https://docs.aws.amazon.com/en_us/AWSEC2/latest/UserGuide/connection-prereqs-general.html
This is AWS-specific, that's why I thought it was going to be an optional thing (maybe under a checkyesno rc variable).