linux - whoami - Can't su to user jenkins after installing Jenkins




switch to jenkins user (2)

I've installed jenkins and I'm trying to get into a shell as Jenkins to add an ssh key. I can't seem to su into the jenkins user:

[[email protected] /]# sudo su jenkins
[[email protected] /]# whoami
root
[[email protected] /]# echo $USER
root
[[email protected] /]# 

The jenkins user exists in my /etc/passwd file. Runnin su jenkins asks for a password, but rejects my normal password. sudo su jenkins doesn't seem to do anything; same for sudo su - jenkins. I'm on CentOS.


as root, enter su - jenkins

Also, check in /etc/passwd that user jenkins is allowed to logon: there should be something like /bin/bash or /bin/sh, certainly not /bin/false at the end of the line.

Hint: You don't use su and sudo at the same time.


jenkins is a service account, it doesn't have a shell by design. It is generally accepted that service accounts shouldn't be able to log in interactively.

I didn't answer this one initially as it's a duplicate of a question that has been moved to server fault. I should have answered rather than linked to the answer in a comment.

if for some reason you want to login as jenkins, you can do so with: sudo su -s /bin/bash jenkins





jenkins