Jenkins ssh into slave without executing .bashrc or .bash_profile as expected

6,601 views
Skip to first unread message

hhuynh

unread,
Jun 9, 2011, 4:19:48 PM6/9/11
to Jenkins Users
Does anyone know what might be wrong when Jenkins won't run .bashrc
or .bash_profile after it ssh into a slave (Suse10 box)?

I have other redhat slaves configuring the same way and the .bashrc is
executed and printed out on Jenkins log but not this Suse10 box.


Fred Stluka

unread,
Jun 9, 2011, 4:40:40 PM6/9/11
to jenkins...@googlegroups.com
I ran into a similar situation involving bash and ssh (but not
Jenkins).  Neither .bash_profile nor .bashrc ran when I used
the -t option on ssh to connect to a server as a user whose
default shell was bash.  Here's what I learned, and my
workaround:

    http://bristle.com/Tips/Unix.htm#use_scripts_for_frequent_ssh_access_to_bash

Maybe your problem is similar?
--Fred
---------------------------------------------------------------------
Fred Stluka -- mailto:fr...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.
---------------------------------------------------------------------

hhuynh

unread,
Jun 9, 2011, 5:40:49 PM6/9/11
to Jenkins Users
Thanks Fred but that workaround doesn't help me with Jenkins setup.

There's no fields in Jenkins slave configurations to let you run any
command. Just hostname, username and password. Jenkins handles the ssh
completely from there.



On Jun 9, 1:40 pm, Fred Stluka <f...@bristle.com> wrote:
> I ran into a similar situation involving bash and ssh (but not
> Jenkins).  Neither .bash_profile nor .bashrc ran when I used
> the -t option on ssh to connect to a server as a user whose
> default shell was bash.  Here's what I learned, and my
> workaround:
>
> http://bristle.com/Tips/Unix.htm#use_scripts_for_frequent_ssh_access_...
>
> Maybe your problem is similar?
>
> --Fred
> ---------------------------------------------------------------------
> Fred Stluka -- mailto:f...@bristle.com --http://bristle.com/~fred/
> Bristle Software, Inc --http://bristle.com-- Glad to be of service!

Jesse Farinacci

unread,
Jun 9, 2011, 4:29:08 PM6/9/11
to jenkins...@googlegroups.com
Greetings,

On Thu, Jun 9, 2011 at 4:19 PM, hhuynh <hhu...@gmail.com> wrote:
> Does anyone know what might be wrong when Jenkins won't run .bashrc
> or .bash_profile after it ssh into a slave (Suse10 box)?

Most likely a user error. Are you certain the $SHELL is bash on the
SuSE10 box? Is /etc/profile dramatically different?

> I have other redhat slaves configuring the same way and the .bashrc is
> executed and printed out on Jenkins log but not this Suse10 box.

User error further confirmed that it is not likely to be a Jenkins
issue because you confirm it is working on other Linux slaves.

-Jesse

--
There are 10 types of people in this world, those
that can read binary and those that can not.

Sami Tikka

unread,
Jun 12, 2011, 4:08:27 PM6/12/11
to jenkins...@googlegroups.com
With high probability this is not a problem with Jenkins but in your slave host.

You should study the bash man page paying attention to which files bash executes for non-login, non-interactive shells. Then check those files and find why they don't work the way you expect them to.

IMHO bash does not execute .bashrc for non-interactive non-login shells. If it does on your other slaves, then they have something special in their bash.

By the way, are you sure the login shell is bash?

Sami

hhuynh

unread,
Jun 13, 2011, 3:38:41 PM6/13/11
to Jenkins Users
I can confirm that it's running bash. My redhat, suse 10 32bit and
windows slaves (using sshd cygwin) are all executing .bashrc file
(or .bash_profile which in turn runs .bashrc) without any extra
setup.

Only this particular Suse 10 64bit that giving me problem. I
understand it's not Jenkins problem but sometimes I wish Jenkins
allows me to specify a command to run during its ssh session. That
way, I can make Jenkins run "bash -l" as part of its ssh command.

R. Tyler Croy

unread,
Jun 13, 2011, 10:05:27 PM6/13/11
to jenkins...@googlegroups.com

On Mon, 13 Jun 2011, hhuynh wrote:

> I can confirm that it's running bash. My redhat, suse 10 32bit and
> windows slaves (using sshd cygwin) are all executing .bashrc file
> (or .bash_profile which in turn runs .bashrc) without any extra
> setup.
>
> Only this particular Suse 10 64bit that giving me problem. I
> understand it's not Jenkins problem but sometimes I wish Jenkins
> allows me to specify a command to run during its ssh session. That
> way, I can make Jenkins run "bash -l" as part of its ssh command.
>

Does the user you're using to log into the SUSE 10 slave have a password set?
I've run into issues before with openSUSE where my SSH logins were "funky" when
accessing it over SSH

- R. Tyler Croy
--------------------------------------
Code: http://github.com/rtyler
Chatter: http://identi.ca/agentdero
http://twitter.com/agentdero

Sami Tikka

unread,
Jun 19, 2011, 7:49:56 AM6/19/11
to jenkins...@googlegroups.com
There are workarounds.

You can choose to change the slave type from ssh slave to "execute command on the master". Then you can specify the command as: ssh HOST 'bash -l -c "java -jar slave.jar"'

The downside is that you have copy slave.jar to the host and also update it when you upgrade Jenkins.

Another workaround is to define the environment variables you normally have in .bashrc in the Jenkins slave node settings.

-- Sami

Hung Huynh

unread,
Jun 20, 2011, 6:09:07 PM6/20/11
to jenkins...@googlegroups.com
Those are great workaround. Thanks Sami. However, I did find out the root cause of this problem. Turns out it's a bug in sshd https://bugzilla.redhat.com/show_bug.cgi?id=458839

Downgrade sshd version to a known working one has worked great.

Thanks again for all who replied.

Hung-

Alan Hu

unread,
Jul 25, 2018, 8:04:19 AM7/25/18
to Jenkins Users
Hi , Please disconnect and reconnect hudson slave, follow the steps mentioned in the link below:




在 2011年6月10日星期五 UTC+8上午4:19:48,hhuynh写道:
Reply all
Reply to author
Forward
0 new messages