2

I have installed Jenkins and I have jenkins as a user in my /etc/passwd:

jenkins:x:995:993:Jenkins Continuous Integration Server:/var/lib/jenkins:/bin/bash
nginx:x:994:992:Nginx web server:/var/lib/nginx:/sbin/nologin
setroubleshoot:x:993:990::/var/lib/setroubleshoot:/sbin/nologin

I have tried to su - jenkins while root and I get this response:

[root@li1078-244 ~]# su - jenkins
Last login: Sun Nov  6 02:50:18 UTC 2016 on pts/0
su: failed to execute /bin/bash : No such file or directory

I want to su - jenkins into bash so I can continue some configurations. I thought I would login as jenkins, but I can't, I get this:

ldco2016@DCortes-MacBook-Pro-3 ~ $ ssh jenkins@localhost                             [ruby-2.3.1]
jenkins@localhost's password:
Permission denied, please try again.
  • Do you have password for jenkins user? Do you have /bin/bash? – Jakuje Nov 6 '16 at 8:16
  • Yes, I have a password for jenkins user, in fact, I even went in as root and changed the password and I am still unable to login as that user. Now I am wondering if its a permissions issue. – Daniel Nov 6 '16 at 14:56
  • It looks like your attempts to switch to the Jenkins user are from two different systems; perhaps a linux instance and a Mac? Can you be specify which one is the main system you are trying this on? I'll propose an answer below but its more specific to linux systems. – Michael J Jan 24 '17 at 0:42
5

On many installations, the login shell for the Jenkins user is set to false or nologin:

$ grep jenkins /etc/passwd
jenkins:x:495:441:Jenkins Continuous Integration Server:/var/lib/jenkins:/bin/false

So if you try to login as or switch to the Jenkins user, the system will not allow it.

The best way to work around this is to start a shell using the Jenkins user:

$ sudo su - jenkins -s/bin/bash
-bash-4.1$ whoami
jenkins
-bash-4.1$ echo $HOME
/var/lib/jenkins
-bash-4.1$
-bash-4.1$ cd .ssh
-bash-4.1$ pwd
/var/lib/jenkins/.ssh
-bash-4.1$

I use this method to install SSH keys that I want my jenkins server to have access to at the CLI level.

  • thank you for answering this question Michael. As you can see I posted this back in November of last year and I never got any help here and I had to move on to other work. Now thanks to you I can go back and give another crack at Jenkins. – Daniel Jan 24 '17 at 2:47
  • Michael, what I am still not clear on, is how do you copy the id to your jenkins@localhost this way. – Daniel Jan 24 '17 at 2:59
  • @Daniel Indeed! Nothing wrong with picking up on an old question! :D Can you give a bit more detail on what you mean by "copy the id"? I don't follow at the moment. If you give a bit more detail on the task (I see in the question you say "continue some configurations") I might be able to provide a bit more direction. – Michael J Jan 25 '17 at 17:36
  • so when I tried ssh-copy-id jenkins, I would be asked for a password and despite the fact that I provided the correct password, it would not add the key. This is what I remember, without being in my jenkins box right now. – Daniel Jan 27 '17 at 21:24
  • OK I think I understand what you're saying. If you're trying to create a key that your local jenkins user can access, you won't be able to use ssh-copy-id. The best approach will be to run bash with the jenkins user like i described in the answer and then create the key in /var/lib/jenkins/.ssh. That's the location your jenkins user will use to look for keys by default. if you're trying to copy a key up to a remote server, scp the key up with your usual account and then move it over to the jenkins account. If i understand the situation correctly, i think that might work. – Michael J Jan 29 '17 at 3:26
2

If you want to log in as Jenkins, you can do so with

sudo su -s /bin/bash jenkins

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.