0

I have a user 'test' and I had modified /etc/passwd file to run a certain script of my own (lets call it somescript.sh) whenever 'test' logs-in or does ssh.

I later changed the '/etc/passwd' file to run '/bin/bash' (the default program to run) whenever 'test' login-in or does ssh, but still whenever 'test' logs-in/ssh the previous script (somescript.sh) runs and not bash.

Not sure who to rectify this. Please help. Thanks

EDIT

test:x:1001:1001:test,,,:/home/test:/home/admin/scripts/script.sh ==> before

script.sh is a shell script that accepts users inputs in a loop, there is a option 'quit' on which I break from the loop and the script ends

test:x:1001:1001:test,,,:/home/test:/bin/bash ==> after

1 Answers1

0

Depending on what somescript.sh does there may be better ways to execute it upon login than by using /etc/passwd. If possible you can login as test and use

chsh -s /bin/bash

that should set the login shell for test to bash. Once that has been done there is some great information in this answer about the different scripts that run when the bash shell starts, the order they run in, etc. Once you know the appropriate file you can add the line

source /path/to/somescript.sh

to that file and it will run every time the user logs in.

Matt
  • 2,781