Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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).

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

2 Answers 2

up vote 7 down vote accepted

try:

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

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

share|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 '12 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 '12 at 14:15
    
You can not do it using script if user have shell like this. –  user106666 Jan 17 '12 at 14:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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