#kirkstone #yocto [openembedded-core] openssh/sshd
Dear Yocto Community,
I made a small dev image, which is perfectly booting (on a Enclustra card).
However when I tried to connect to the machine using ssh it failed (connection reset by peer).
After a quick look at how the socket-based activation works and the systemd service dependencies,
I connected to the machine via a serial port and performed the individual program calls manually.
I noticed that the sshd service requires the sshd_check_keys shell script to be executed.
This script creates host keys if they are not provided, and the private (and public) keys are generated
with default permissions (644). The problem appears when the ssh program checks the key file permissions and finds them "too open". I tweaked the shell script by adding a line chmod 0600 "$FILE" just after the line mv "${FILE}.tmp" "$FILE" and this hack works perfectly. So finally, I just created a patch which adds this line.
I might be wrong, but I tend to believe this should have worked without this workaround.
Does somebody have an idea of what could be incorrectly set up (a variable?) or what should be done in the image to prevent this from happening? Thank you in advance
Regards,
JM
Thanks for reporting this issue here,
ssh-keygen typically creates private key files with permissions set to 644 (readable by owner and group). Which
could be too permissive for private ssh keys so changing the permissions after creation is right thing to do your patch looks like we need upstream too, something like below might work, if it works please consider sending it as a patch to oe-core mailing list.
(quoted diff) +0 -0
b/meta/recipes-connectivity/openssh/openssh/sshd_check_keys index 606d1894b55..fae2bc5d16c 100644
meta/recipes-connectivity/openssh/openssh/sshd_check_keys +1 -1
@@ -8,7 +8,7 @@ generate_key() { mkdir -p "$DIR" rm -f ${FILE}.tmp ssh-keygen -q -f "${FILE}.tmp" -N '' -t $TYPE - + chmod 0600 "$FILE.tmp" # Atomically rename file public key mv -f "${FILE}.tmp.pub" "${FILE}.pub"
Quoted 29 lines · Jean-Michel Papy via lists.yoctoproject.org
Dear Yocto Community,
I made a small dev image, which is perfectly booting (on a Enclustra card).
However when I tried to connect to the machine using ssh it failed (connection reset by peer).
After a quick look at how the socket-based activation works and the systemd service dependencies,
I connected to the machine via a serial port and performed the individual program calls manually.
I noticed that the sshd service requires thesshd_check_keysshell script to be executed.
This script creates host keys if they are not provided, and the private (and public) keys are generated
with default permissions (644). The problem appears when the ssh program checks the key file permissions and finds them "too open". I tweaked the shell script by adding a line chmod 0600 "$FILE" just after the line mv "${FILE}.tmp" "$FILE" and this hack works perfectly. So finally, I just created a patch which adds this line.I might be wrong, but I tend to believe this should have worked without this workaround.
Does somebody have an idea of what could be incorrectly set up (a variable?) or what should be done in the image to prevent this from happening? Thank you in advance
Regards,
JM-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
You automatically follow any topics you start or reply to. View/Reply Online (#63982): https://lists.yoctoproject.org/g/yocto/message/63982
Mute This Topic: https://lists.yoctoproject.org/mt/108904954/1997914
Mute #kirkstone:https://lists.yoctoproject.org/g/yocto/mutehashtag/kirkstone Mute #yocto:https://lists.yoctoproject.org/g/yocto/mutehashtag/yocto Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Dear Khem,
Thank you for your answer and for the patch.
I tested both changing permissions before and after file renaming and it works equally well. If you do not mind I'd like to have your opinion about the most preferred way of doing a modification of recipe via a bbappend:
1) providing patch and letting bitbake apply it
2) providing a modified file and letting bitbake replace the original one Thank you in advance
Best regards
Quoted 9 lines · Jean-Michel Papy via Lists.Yoctoproject.Org
Dear Khem,
Thank you for your answer and for the patch.
I tested both changing permissions before and after file renaming and it works equally well. If you do not mind I'd like to have your opinion about the most preferred way of doing a modification of recipe via a bbappend:
1) providing patch and letting bitbake apply it
2) providing a modified file and letting bitbake replace the original one
For your own layer using a bbappend might work better, you have to take the change you did and apply it via do_install:append I will send the upstream patch with your credits added.
Quoted 2 lines
Thank you in advance
Best regards
Quoted 16 lines · Khem Raj
Quoted 10 lines · Jean-Michel Papy via Lists.Yoctoproject.Org
Dear Khem,
Thank you for your answer and for the patch.
I tested both changing permissions before and after file renaming and it works equally well.
If you do not mind I'd like to have your opinion about the most preferred way of doing a
modification of recipe via a bbappend:
1) providing patch and letting bitbake apply it
2) providing a modified file and letting bitbake replace the original one
Quoted 3 lines
For your own layer using a bbappend might work better, you have to take the change you did and apply it via do_install:append I will send the upstream patch with your credits added.
Ok fine for me :)
thanks !
Quoted 7 lines
Quoted 5 lines
Thank you in advance
Best regards