Unfortunately neither /etc/profile nor ~/.profile won't be parsed if
shell is non-interactive. Simplest example will be:

if the content of /etc/profile is:

MY_ENV=DEV
export MY_ENV

Then if I login to the host like this:

ssh [email protected]

myopenbsdhost$ env

_=/usr/bin/env
LOGNAME=username
PWD=/home/username
HOME=/home/username
SSH_TTY=/dev/ttyp0
MY_ENV=DEV
TERM=xterm-256color
SHELL=/bin/ksh
...blabla...


So OK in this case. But if I run:


ssh [email protected] env

_=/usr/bin/env
LOGNAME=username
PWD=/home/username
HOME=/home/username
SSH_TTY=/dev/ttyp0
SHELL=/bin/ksh
...blabla...


Got the idea? Other BSDs and Linux behaves exactly the same way,
/etc/profile and ~/.profile are parsed for interactive shells only.


On 06.11.20 15:56, Dante Catalfamo wrote:
> Hey Kirill,
>
> The default shell in OpenBSD is usually ksh unless otherwise
> specified. You should check out the ksh(1) man page.
>
> You should be able to achieve what you want by setting the variable in
> /etc/profile. Hope that helps.
>
> Dante
>
> On 2020-11-06 6:23 a.m., Kirill Peskov wrote:
>> Hi All,
>>
>> I'm currently trying to figure out, how to set global environment
>> variable, valid for multiple users including root, so Ansible will be
>> able to accept it as "fact" for both root and non-root users. I've
>> already tried to play with .cshrc files and /etc/rc.local, nothing
>> worked so far, looks like I'm missing something important.
>>
>> Thanx in advance,
>>
>> Kirill
>>
>>

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to