What is the default Jenkins password?

2019-01-08 19:46发布

问题:

I'm using a EC2 server instance. Used the following to install Jenkins:

wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins

but I need to install software on the Jenkins server so in my EC2 instance I did

sudo –s –H –u jenkins

to get into the jenkins server. Then I tried to do

sudo cabal install quickcheck

but it prompted me for jenkins password. I've been searching around the internet for 4hrs now and nothing is helping me get administrative privilege in the jenkins server.

So I'm building my project using the following command in shell:

sudo cabal clean
sudo cabal configure
sudo cabal build
sudo cabal install

This is the error I'm getting:

 Started by timer
Building in workspace /var/lib/jenkins/jobs/Finance/workspace
Checkout:workspace / /var/lib/jenkins/jobs/Finance/workspace - hudson.remoting.LocalChannel@eea6dc
Using strategy: Default
Last Built Revision: Revision b638e2182dece0ef1a40232b1d75fa3ae5c01a5d (origin/master)
Fetching changes from 1 remote Git repository
Fetching upstream changes from origin
Commencing build of Revision b638e2182dece0ef1a40232b1d75fa3ae5c01a5d (origin/master)
Checking out Revision b638e2182dece0ef1a40232b1d75fa3ae5c01a5d (origin/master)
[workspace] $ /bin/sh -xe /tmp/hudson3500373817395137440.sh
+ sudo cabal clean
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: 3 incorrect password attempts
Build step 'Execute shell' marked build as failure
Sending e-mails to: coolhhc@gmail.com
ERROR: Could not connect to SMTP host: localhost, port: 25
javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
  nested exception is:
    java.net.ConnectException: Connection refused
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1934)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638)
    at javax.mail.Service.connect(Service.java:295)
    at javax.mail.Service.connect(Service.java:176)
    at javax.mail.Service.connect(Service.java:125)
    at javax.mail.Transport.send0(Transport.java:194)
    at javax.mail.Transport.send(Transport.java:124)
    at hudson.tasks.MailSender.execute(MailSender.java:116)
    at hudson.tasks.Mailer.perform(Mailer.java:117)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:814)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:786)
    at hudson.model.Build$BuildExecution.post2(Build.java:183)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:733)
    at hudson.model.Run.execute(Run.java:1592)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:237)
Caused by: java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
    at java.net.Socket.connect(Socket.java:579)
    at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:286)
    at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:231)
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1900)
    ... 17 more
Finished: FAILURE

回答1:

Here is how you can fix it:

  • Stop Jenkins
  • Go go edit /var/lib/jenkins/config.xml
  • Change <useSecurity>true</useSecurity> to false
  • Restart Jenkins: sudo service jenkins restart
  • Navigate to the Jenkins dashboard to the "Configure Security" option you likely used before. This time, setup security the same as before, BUT set it to allow anyone to do anything, and allow user signup.
  • Go to www.yoursite.com/securityRealm/addUser and create a user
  • Then go change allow anyone to do anything to whatever you actually want users to be able to do. In my case, it is allow logged in users to do anything.


回答2:

If you installed using apt-get in ubuntu 14.04, you will found the default password in /var/lib/jenkins/secrets/initialAdminPassword location.



回答3:

Before installing jenkins, create a user named jenkins and set password there. Then after installing jenkins you can use the password you created.



回答4:

jenkins default administrator password is logged in log file in ubuntu

log file is situated in /var/log/jenkins/jenkins.log folder

password will be placed after this, Jenkins initial setup is required. An admin user has been created and a password generated. Please use the following password to proceed to installation:



回答5:

With the default Jenkins installation using Homebrew on macOS this will output the initial password for the admin user:

sudo cat /Users/Shared/Jenkins/Home/secrets/initialAdminPassword


回答6:

I don't believe that the Jenkins user that is installed via apt has a password. If it does, I have never seen documentation. Based on the commands you entered, I am guessing you are using a Debian distro?

Is there any particular reason you must use the jenkins user to do the install instead of the user which was set up when you created your instance?



回答7:

You can always disable security, then go in and re-enable it with the settings you want.



回答8:

By default, Jenkins account is created without password and with the login shell as /bin/false.

jenkins:x:496:493:Jenkins Continuous Integration Server:/var/lib/jenkins:/bin/false

Change the shell to /bin/bash and you should be able to login without password by sudo su - jenkins.

Command to change the shell is:

chsh -s /bin/bash jenkin


回答9:

When installing Jenkins from AWS Marketplace . . .

"A default user "admin"with the instance-id as password is created to secure the Jenkins instance."

On the AWS Console for EC2, with the instance selected, choose the "Usage Instructions" tab:

"AWS Marketplace Usage Instructions Latest Versions: 2.19.4.2 A default user "admin"with the instance-id as password is created to secure the Jenkins instance. Once the instance is started, copy the public DNS hostname of the server in the AWS Management Console and enter it in your web browser. The welcome screen allows you to request a trial license, start and evaluation, enter a license key, or connect to your instance to Operations Center. Once the license step is done, your instance is fully functional. We recommend enabling security and backups. You can connect with SSH to the server using the "ubuntu"linux user. The JENKINS_HOME is located under "/var/lib/jenkins". Jenkins listens on the following ports: * HTTP 80: through HAProxy, can be configured to use HTTPS:443 instead * Jenkins SSH 2222: primarily for the CloudBees Git Validated Merge Plugin * Jenkins JNLP 10000: communication from Jenkins agents or Jenkins CLI configured to use JNLP protocol. Not exposed by default on security groups."



回答10:

Similar to the Ubuntu answer above, the Windows admin default password is stored in {jenkins install dir}\secrets\initialAdminPassword file (default install location would it in C:\Program Files (x86)\Jenkins\secrets\initialAdminPassword )



回答11:

I was running Jenkins executing java -jar jenkins.war.

In my case Jenkins wrote webroot in an stdout: webroot: $user.home/.jenkins. So admin secret key was placed in a ~/.jenkins/secrets/initialAdminPassword.



回答12:

After Jenkins is installed just run sudo cat /var/lib/jenkins/secrets/initialAdminPassword.

In the Jenkins login page:

User: admin Password: the output from the above command



回答13:

When you install jenkins on your local machine, the default username is admin and password it gets automatically filled.