How to become a Jenkins user?

17,040

Solution 1

Basically for this Jenkins user jenkins bash was not configured.

jenkins:x:496:492:Jenkins Continuous Build server:/var/lib/jenkins:/bin/false

So we need to set the bash for this user and that resolved the issue. I used the following command:

sudo usermod -s /bin/bash jenkins

See below:

jenkins:x:496:492:Jenkins Continuous Build server:/var/lib/jenkins:/bin/bash

And now I can perform su and can use bash.

Solution 2

It is also possible to run:

su - jenkins -s /bin/bash

Solution 3

It's more like a queastion for superuser but:

You don't need sudo when switching the user. su will ask for the users password anyway:

su - jenkins

You can also use sudo to execute a single command as another user with the -u option. If that command is a shell, you'll get a shell. E.g.:

sudo -u jenkins /bin/bash
Share:
17,040
Exploring
Author by

Exploring

I enjoy making computer to work for me!

Updated on July 22, 2022

Comments

  • Exploring
    Exploring almost 2 years

    I have installed Jenkins and during installation an user named jenkins has been created. I can see from the documentation:

    The 'jenkins' user is created to run this service.

    Now I need to become this jenkins user. I have in the following ways:

    [root@hostname ~]# sudo su - jenkins
    [root@hostname ~]# id
    uid=0(root) gid=0(root) groups=0(root)
    
    [root@hostname tmp]# su - jenkins
    [root@hostname tmp]# whoami
    root
    

    Why switch user to the jenkins user is not working?

    I am on RHEL.

    cat /etc/*release
    Red Hat Enterprise Linux Server release 6.3 (Santiago)
    
  • prayagupa
    prayagupa about 3 years
    sudo -u jenkins /bin/bash worked without password prompt