Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't su to user jenkins after installing Jenkins

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:

[root@pacmandev /]# sudo su jenkins [root@pacmandev /]# whoami root [root@pacmandev /]# echo $USER root [root@pacmandev /]#  

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.

like image 304
sfendell Avatar asked Aug 05 '13 21:08

sfendell


People also ask

How do I give jenkins a user root permission?

Go to sudoers file by typing below command. While saving the file remember saving it in /etc/sudoers, not in etc/sudoers. tmp. After that restart your Jenkins server by using below command.

What account does jenkins run as?

If you have access to the gui, you can go to "manage jenkins" > "system information" and look for "user.name".


2 Answers

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

like image 176
thekbb Avatar answered Sep 19 '22 11:09

thekbb


Use the below command:

su -s /bin/bash jenkins 
like image 27
Sudipto Das Avatar answered Sep 19 '22 11:09

Sudipto Das