Jenkins User on Apt-Get Install Installation Jenkins User on Apt-Get Install Installation jenkins jenkins

Jenkins User on Apt-Get Install Installation


I'll anticipate that from time to time you'll want to be able to log in as jenkins to do other tasks, and so I'll solve the more general problem. A strict answer to your question is included at the end.

Change jenkins' password without knowing it

From any account which has sudo permissions, you can reset jenkins' password to something of your choosing:

sudo passwd jenkins

You may be asked first for your own password, in order to use sudo. Then you will be prompted for the new password to set for jenkins, and finally a confirmation of that new password.

If your user with sudo rights is called joe, here's how a session might look:

joe $ sudo passwd jenkins[sudo] password for joe:     **you enter joe's passwd**Enter new UNIX password:     ** you enter new jenkins passwd**Retype new UNIX password:    ** you enter new jenkins passwd**passwd: password updated successfully

Alternative: login as jenkins without his password

Alternatively, again using sudo from a suitable other account, you can login as jenkins without being asked for his password:

sudo su - jenkins

An aside: Avoiding password prompt confusion

Before issuing sudo passwd jenkins, we might first like to authenticate separately with sudo to avoid confusion around the question "whose password am I being asked for, now?".

sudo -vsudo passwd jenkins

After a successful authentication by sudo, there is a window (e.g. 15 minutes) where we won't be prompted to authenticate again. (Note that you can immediately invalidate (kill) this session with sudo -k, if you want to experiment.)

The promised strict answer

sudo -u jenkins ssh-keygen

Then use cat to view the contents of the public key to be passed to github (but the path is only an example):

  sudo cat ~jenkins/.ssh/id_rsa.pub

The exact location and name of the public key file depends on what you entered to the prompts of ssh-keygen, above. I've used a shortcut to jenkins' home dir, ~jenkins.

Related Links