0

I need to run custom binary when user logged in to system ,so that I have changed user's shell to /bin/binary to /etc/passwd but I have observed that /etc/profile file was not read when I logged in with changed user's shell

So /etc/profile will be only read if user's shell is /bin/sh in /etc/passwd??

1 Answer 1

5

Not quite. /etc/profile will be read if the user's shell according to /etc/passwd (or LDAP, or other tool) knows how to read it and does it.

If you replace /bin/sh with a binary that doesn't know how to read /etc/profile, then it won't be read.

One way to fix it is obviously to fix the binary so that it knows how to handle /etc/profile.

Another is to keep the user's shell set to /bin/sh, and to edit the user's $HOME/.profile to start the binary after everything else has been set up.

A third way is to make the user log in using an SSH key, and edit the key so that it will start /bin/binary and disregard any other commands. You do this by editing the user's $HOME/.ssh/authorized_keys to read e.g.

 command="/bin/binary"  ssh-dss AA.....restofkeyhere....
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .