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,711
  • 1
  • 13
  • 20
  • chsh did not help. Still facing the same problem. – CodeWithPride Jul 14 '15 at 00:39
  • is there any chance you can post an example of `/etc/passwd` with the changes that were made before and after? obviously not the exact `/etc/passwd` you are using, but if you could boot a live OS image or clean/disposable VM and try to recreate the issue in a clean environment more details and/or step by step snapshots of the relevant files would be useful. On a somewhat related note have you tried deleting and recreating the test user? – Matt Jul 14 '15 at 00:52
  • I have edited the question with before and after changes of /etc/passwd. I have not tried deleting and re-creating test user. – CodeWithPride Jul 14 '15 at 01:01
  • The link to another question really helped. Thanks – CodeWithPride Jul 14 '15 at 23:11