Is there a way to reset all (or just disable the security settings) from the command line without a user/password as I have managed to completely lock myself out of Jenkins
?
相关问题
- Is shmid returned by shmget() unique across proces
- “Zero out” sensitive String data in Swift
- how to get running process information in java?
- High cost encryption but less cost decryption
- Error building gcc 4.8.3 from source: libstdc++.so
I found the file in question located in /var/lib/jenkins called config.xml, modifying that fixed the issue.
step-1 : go to the directory cd .jenkins/secrets then you will get a 'initialAdminPassword'.
step-2 : nano initialAdminPassword
you will get a password
In El-Capitan config.xml can not be found at
Its available in
then after that as other mentioned open the config.xml file and make the following changes
In this replace
<useSecurity>true</useSecurity>
with<useSecurity>false</useSecurity>
Remove
<authorizationStrategy>
and<securityRealm>
Save it and restart the jenkins(sudo service jenkins restart)
In case of Jenkins over a container managed by a Kubernetes POD is a bit more complex since:
kubectl exec PODID --namespace=jenkins -it -- /bin/bash
will you allow to access directly to the container running Jenkins, but you will not have root access,sudo
,vi
and many commands are not available and therefore a workaround is needed.Use
kubectl describe pod [...]
to find the node running your Pod and the container ID(docker://...)
SSH
into the nodedocker exec -ti -u root -- /bin/bash
to access the container with Root privilegesapt-get update
sudo apt-get install vim
The second difference is that the Jenkins configuration file are placed in a different path that corresponds to the mounting point of the persistent volume, i.e.
/var/jenkins_home
, this location might change in the future, check it runningdf
.Then disable security - change true to false in
/var/jenkins_home/jenkins/config.xml
file.Now it is enough to restart the Jenkins, action that will cause the container and the Pod to die, it will created again in some seconds with the configuration updated (and all the chance like vi, update erased) thanks to the persistent volume.
The whole solution has been tested on Google Kubernetes Engine. UPDATE Notice that you can as well run
ps -aux
the password in plain text is shown even without root access.Edit the file $JENKINS_HOME/config.xml and change de security configuration with this:
After that restart Jenkins.
To disable Jenkins security in simple steps in Linux, run these commands:
It will remove
useSecurity
andauthorizationStrategy
lines from yourconfig.xml
root config file and restart your Jenkins.See also: Disable security at Jenkins website
After gaining the access to Jenkins, you can re-enable security in your Configure Global Security page by choosing the Access Control/Security Realm. After than don't forget to create the admin user.