Adding "bot" credentials to jenkins when using Unix user/group database - jenkins

We're using Jenkins server (v. 1.571) with the following authorization configuration:
Security Realm: Unix user/group database.
Authorization: Matrix-based security
up until now, each member of our team used its private credentials to login and perform operations on this server.
We want to enable bot scripts to login to the server with "global" credentials and perform some of these operations, without changing the current credentials of the users (and hopefully, don't touch the current authorization guidelines).
How can this be achieved?
thanks!

You can check Mask Passwords Plugin. It provides you the option to define user and password in Manage Hudson > Configure System section. To add to it, as the name suggests, the password will be masked in the console output. Even in the Configure section where you create user and password, the password will remain in masked state.

Related

jenkins api authentication failure

I am using oauth authentication for jenkins. I can successfully make api calls if i use my_user_name:api_token when my user name is explicitly configure in global security. It fails when my user name does not exist but a group which contains the user name and has all permissions.
Any idea about this phenomenon ?
thanks in advance
The Jenkins api-token is obtained for a specific user http://<jenkins-server>/user/<username>/configure and can be used for that same user only.

Issue with jenkins security

I installed a fresh copy of jenkins 1.609 and configured one job (I had multiple instances of previous jenkins versions earlier). I wanted to protect this instance, in particular protect the jobs and everything, since it runs on the internet.
When I activate security, and check jenkins-own user database checkbox as well as logged-in users can do everything checkbox and save it, it seems to have no effect, as anonymous user is still able to access the job and the workspace of the job.
When I active use-matrix-based security and give my user admin (actually all) rights, the job isn't visible anymore, but I lose all privileges and I see
<username> is missing the Overall/Administer permission
immediately. After that I have no access to administration overview anymore.
So question from my side, what should I choose if I want the anonymous user to see a blank page, and logged in user to do everything.
The solution is choose the "Matrix-based security" option with the configuration below:
Then, you just have to set the relevant permissions to authenticated users.
Anonymous users will not be able to access your Jenkins server :)

How to setup credentials for every project in Jenkins?

I have some 10 projects in my Jenkins , each for 10 different clients . So i need to create credentials for all my projects , so that each client can access only their project .
Is there any plugin to achieve my requirement .??
Please Help !!!
Select "Project-based Matrix Authorization Strategy" under Global Security
Define general users, without access to projects at this level.
Then on per-project select "Enable project-based security", and here you can give individual users addition permissions, such as ability to view and execute the job
Edit:
In Configure Global Security, under Project-based Matrix Authorization:
Make sure Anonymous and Authenticated don't have any other permissions.
Give Anonymous:
Job Discover (this will redirect non-logged in users to login page).
Give Authenticated:
Overall Read (without this permission, nothing else will work).
View Read, optional (without this, they won't see custom views, just the 'all view').
Save configuration
In Job Configuration, under Enable project-based security:
Give client1:
Job Read (this will allow to view this particular job, and nothing else).
Give additional permissions as required (build, workspace, promote, etc).
Save configuration

Is it possible to get Jenkins password in build job

I am not sure if this was already asked/ discussed before.
In my Jenkins, I have setup LDAP authentication and that password is required in one of my jobs to remotely login to a different server using that password and execute some tasks there
Assume the remote task is executed via sshexec in ant task which requires username password. I dont want the user to enter the password again in the form of a build paramater, is there a way to get the password used for Jenkins authentication inside the build job ???
[I]s there a way to get the password used for Jenkins authentication inside the build job?
Not as such. Jenkins does not retain the password after you log in, it simply passes it to the LDAP server long enough to verify that you should be authenticated.
So what you need is to define Credentials persisted in Jenkins that can be used during a build. You can use the Credentials Binding plugin to set up a fixed username/password which the job will have access to.
If your requirement is for the credentials to not be available for any build of the job, but instead that a user manually initiating the build should have to supply them (meaning that scheduled or otherwise triggered builds are impossible), I think this is also supported as of version 1.1. Define a parameter of credentials type for the job, to be used via variable expansion in the binding. Then have the user define these credentials in their user configuration page (/me/configure). Then when selecting Build with Parameters they should see their own personal credentials and be able to select them. The user needs the Credentials/UseOwn permission on the job.
Another option for the future would be a subtype of username/password credentials which does not store the password at all (maybe just a “salted” hash, using jBCrypt), and somehow prompts for you to enter the password before the credentials are considered valid, probably expiring after a few minutes. This mode has not been implemented but would be useful for sites with stricter security requirements.
(Regular credentials are stored encrypted, but the default secure storage mechanism keeps the master encryption key in $JENKINS_HOME—so secure so long as you do not allow shell access to your server to anyone who is not already a Jenkins administrator, and of course so long as you configure the master computer to have zero executors so people cannot run builds on it, only on slaves. Another RFE would be an alternate storage mechanism that allows the master key to be injected by some other means.)
The best possible way to do is to allow permission to jenkins user in the remote server.

How to make Jenkins hide logs, history, etc on front page?

I want to remove all changes, workspace links and logs from Jenkins front page.
I do not want unauthorized people, bots, etc to have access to this kind of information.
How can I do that?
Set up your permissions to not allow unauthorized access
WARNING:
Make sure you have your own user/admin setup will all permission, otherwise you risk locking yourself out. If you do, use information here to reset [thanks Alex]
To configure anonymous users to not see anything:
Go to Manage Jenkins
Click Configure System/Configure Global Security (depending on your Jenkins/Hudson configuration)
Under Access Control -> Security Realm, you should have either Matrix-based security or Project-based Matrix Authorization Strategy. I will assume you've selected the later.
Under User/group to add: type authenticated and click Add
Now, give this group all the permissions that you want them to have.
Next, under User/group to add: type Anonymous and click Add
Make sure that none of the permissions are given to this group
Click Save
This way, anonymous (not-logged in) users will not be able to see anything, but authenticated (logged in) users will be able to see what you selected. You can drill-down into more specific user permissions by adding individual users and granting them certain permissions.
P.S. The user authentication depends on your Security Realm configuration. You can configure to use Active Directory/LDAP, or use Jenkin's own user database. The former means you don't have to create users in Jenkins, just give them permissions. The later means you've got to create Jenkins's users first through Manage Jenkins -> Manage Users

Resources