Skip to main content

how to avoid sudo su -s /bin/bash jenkins [Resolved]

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?


Asked March 20, 2017
Tags: jenkins
Posted Under: Network
38 views
1 Answers

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/tomcat:/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/tomcat:/bin/bash

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


Answered March 20, 2017
 
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 1 hour ago
 CanDoerz  3 months ago
Your Answer
D:\Adnan\Candoerz\CandoProject\vQA