0

I used to be able to change to jenkins user from root by doing su jenkins

but with my new jenkins installation, I have to do sudo su -s /bin/bash jenkins

does anyone know how I can just do su - jenkins again?

Hasmine
  • 3
  • 1
  • 2

1 Answers1

4

Look at the shell specified in /etc/passwd for the jenkins user. You can do so by running something like:

grep jenkins /etc/passwd

The output will look similar to this:

jenking:1001:1001::/usr/local/jenkins:/bin/false

The last field is the login shell of the user. Here you can see it is set to /bin/false which will immediately exit.

The solution is to specify which shell to use as you described:

su -s /bin/bash jenkins

Or modify the login shell of the jenkins user with "usermod(8)" (executed as a root user) :

usermod -s /bin/bash jenkins

Then grep jenkins /etc/passwd should now output something like:

jenkins:1001:1001::/usr/local/jenkins:/bin/bash

After which. su - jenkins will work as you expect.

Nico
  • 156
  • 6
  • 1
    And you may think about if you really want a jenkins shell. For config files editing as root may make sense (because then processes running as jenkins cannot modify it), when running commands as jenkins ``sudo`` may be a better alternative. – allo Mar 20 '17 at 18:58