[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ssh does not source /etc/bash.bashrc, but manual execution of /bin/b

From: Chet Ramey
Subject: Re: ssh does not source /etc/bash.bashrc, but manual execution of /bin/bash does it under specific circumstances
Date: Tue, 20 Dec 2016 13:24:56 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.5.1

On 12/20/16 11:11 AM, Nick wrote:

>         i came up with a weird behavior of ssh+bash on my Debian box (8.6).
>         I created an alias in /etc/bash.bashrc file, which is sourced through 
> /etc/profile.
>         Everything worked fine, till i decided to remove the '. 
> /etc/bash.bashrc' line from /etc/profile.
>         When i` m connected via ssh the '/etc/bash.bashrc' is not sourced and 
> the alias does not work as expected.
>         But, when i execute bash from my shell, the '/etc/bash.bashrc' seems 
> to be sourced and the alias is there (please find bellow a demo)

ssh without a command is equivalent to slogin, which starts a login shell
on the remote host.  Login shells don't execute ~/.bashrc (and, if so
configured, SYS_BASHRC), so there's usually a line to source it in one of
the login shell startup files (/etc/profile in your case).  That's why
it's there, and that's why removing it had the effect you observed.

>         Not sure if i miss something (f.x. bash is executed with different 
> flags while being called from ssh versus a user), but as far as i understand, 
> the same things should be (or not) sourced.

Well, it's the difference between a login shell and a non-login interactive

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]