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
shell.

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

Reply via email to