9

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

Kenny Rasschaert
  • 8,925
  • 3
  • 41
  • 58
Karl
  • 93
  • 1
  • 1
  • 3

2 Answers2

17

try:

su myuser -s /bin/sh -c /home/myuser/script.sh
mrc
  • 1,446
  • 11
  • 12
0

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

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