On a RedHat system, i'm trying to launch a program with a different user who dont have any shell. In /etc/passwd, shell is /sbin/nologin.

I have tried:

  1. su myuser -c /home/myuser/script.sh Result: This account is currently not available.

  2. With chown and setuid: chown myuser:mygroup /home/myuser/script.sh chmod +s /home/myuser/script.sh /home/myuser/script.sh Result: script.sh is still executed as my signed in user (root).

link|improve this question
Are you running the su as root or an unprivileged user? – James O'Gorman Jan 17 at 14:23
feedback

2 Answers

up vote 6 down vote accepted

try:

su myuser -s /bin/sh -c /home/myuser/script.sh
link|improve this answer
Thanks you. It works! It was simple... :) – Karl Jan 17 at 14:33
feedback

this error means that in /etc/passwd you have set shell /sbin/nologin or /sbin/false for user myuser.

Please set something usefull like /bin/bash

link|improve this answer
That's what the OP already posted was happening; OP is asking if there's a way to run the program despite the username having no shell. – Bart Silverstrim Jan 17 at 14:13
Yes... It is the question in fact. I would like to know if it is possible to run a script as a different user, without setting a shell in /etc/passwd – Karl Jan 17 at 14:15
You can not do it using script if user have shell like this. – rkosegi Jan 17 at 14:17
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.