Bug 15767

Summary: openssh session don't use /etc/environment nor /etc/security/pam_env.conf
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Trent Piepho <trent.piepho>
Component: connectivityAssignee: Mingli Yu <mingli.yu>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: ccasciato, meta.mr.watcher, meta.watcher, mingli.yu, randy.macleod, yoann.congal
Version: 5.0.7   
Target Milestone: 5.3 M1   
Hardware: x86   
OS: x86_64   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Trent Piepho 2025-02-20 21:26:09 UTC
It should be possible to add environment variables to all sessions via /etc/environment or in /etc/security/pam_env.conf

This works for console logins, but not with openssh logins.

The problem appears to be that nothing in /etc/pam.d/sshd will load pam_env.so.

Perhaps the libpam package should add this to /etc/pam.d/common-session?  This file is referenced by the sshd pam configuration.  E.g., add this:
>session required        pam_env.so readenv=1
Comment 1 Randy MacLeod 2025-02-27 15:33:37 UTC
Interesting suggestion. Debian does this.

Can you send a patch to the list?
https://docs.yoctoproject.org/contributor-guide/index.html
Comment 2 Randy MacLeod 2025-03-21 20:12:11 UTC
Trent do you have time for this?
I've CCed Mingli who may be able to work on it if you can't or if you don't reply by March 25, 2025.
Comment 3 Randy MacLeod 2025-04-10 15:02:36 UTC
Mingli, Can you work on this and maybe email Trent if needed.
He didn't reply to the YP BZ NEEDINFO emails.
Comment 5 Clayton Casciato 2026-01-28 17:43:36 UTC
[meta-selinux][PATCH 0/1] openssh: Add pam_env support
https://lists.yoctoproject.org/g/yocto-patches/topic/meta_selinux_patch_0_1/117511888

[meta-selinux][PATCH 1/1] openssh: Add pam_env support
https://lists.yoctoproject.org/g/yocto-patches/topic/meta_selinux_patch_1_1/117511975