machine A --RHEL 7 and updated.
machine B -- RHEL 6 and updated.

If I do this on A (RHEL 7)

ssh B

I get in, like I should, but my .bashrc has NOT been run. This is new behavior to me. I want my .bashrc to be run on the machine B (RHEL 6). I did diffs on the /etc/ssh/sshd_config and /etc/ssh/ssh_config, and they are different but I don't see why these should matter.

ssh_config differs only by whitespace and comments.

Yes, I saw the stuff but even with that it mangled the diff output because of the less than/greater than in it. Is there something in there that I should care about? I hacked and slashed, other than whitespace, comments, and environment variable (AcceptEnv) here is what the diff boiled down to.

the 6 side

Protocol 2

the 7 side

HostKey /etc/ssh/ssh_host_ecdsa_key
AuthorizedKeysFile  .ssh/authorized_keys
UsePrivilegeSeparation sandbox

So, where do I look to find out why my .bashrc won't run? My .profile, again:

alias lo='exit'
alias l='ls -CF'
alias ..='cd ..'

and my .bashrc:

export PRINTER

export DISPLAY


export PATH

export PROXY

cd /home/gl

if [ -f /etc/bashrc ]; then
        . /etc/bashrc

/etc/bashrc is stock.


Perhaps the documentation is confusing but Bash's standard behavior is to source your "profile" (.bash_profile, .bash_login, .profile whichever it finds first in that order) on interactive login shells and .bashrc on interactive non-login shells.

Sshd typically spawns a login shell where opening an X11 terminal window is typically a non-login shell.

So you should not expect your .bashrc to be read when you ssh into a machine.

That said I generally recommend users add a line like the following to their "profile"

[[ -r ~/.bashrc ]] &&  source ~/.bashrc

Finally, /etc/bashrc is never directly read by Bush and you'll find no mention of it in the bash man page. It's a file RedHat added and the expectation is that your ~/.bashrc file will source it. The default ~/.bashrc that should have been in your home directory when your account was created should be doing that. If not, you should find an example in the /etc/skel directory.


The ~/.bashrc file does not always get read: see Bash Startup Files in the manual.

Does your ~/.bash_profile (or ~/.profile) invoke your .bashrc file? Often this appears in .profile files:

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"

In the end, I sourced the .bashrc from the .profile. For me, this means the .profile must be empty except for running .bashrc to avoid circular references and other confusion.

As I've read in the man page, sshd should have invoked the .bashrc, but, oh well, I have a workaround.

Your Answer

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