We just upgraded OpenSSH on our Solaris systems from 4.7p1 to 5.1p1. Now bash no longer executes .bashrc when a user starts a non-interactively ssh session. Note that this is for Solaris 9 and 10. From the bash man page (under INVOCATION): "When bash is started non-interactively, to run a shell script, for example, it looks for the variable BASH_ENV in the environment, expands its value if it appears there, and uses the expanded value as the name of a file to read and execute." If I set BASH_ENV in ~/.ssh/environment (and set PermitUserEnvironment to "yes" in sshd_config) then I can run any file I specify. Setting this option, however, does not sound safe for normal use. "Bash attempts to determine when it is being run by the remote shell daemon, usually rshd. If bash determines it is being run by rshd, it reads and executes commands from ~/.bashrc, if that file exists and is readable." I have tried several versions of bash including the latest (v3.2) and all exhibit the problem with OpenSSH 5.1p1; .bashrc should run but it doesn't. This leads me to believe that OpenSSH is the culprit. Interactive login sessions work fine; bash runs .bash_profile as per the INVOCATION section. Also works fine with older versions of OpenSSH.
I experience what seems to be the same problem on Fedora Core 9, version: openssh-5.1p1-2.fc9
The current openssh server uses pipes instead of sockets to communicate with the shell. bash recognized stdin as socket and called .bashrc in this case. With pipe as stdin the bash runs as any other non-interactive shell and doesn't read .bashrc. There is also possibility to recompile bash so it recognizes ssh through the environment variable SSH_CLIENT.
The problem here is bash making an unwarranted assumption about the environment it operated in. OpenSSH has always used either pipes or socketpairs depending on the operating system it was running on, so bash's assumption was incorrect for platforms other than Linux anyway. Apparently there is compile-time flag that one can set for bash that resolves the problem: https://bugzilla.redhat.com/attachment.cgi?id=321287&action=diff (I haven't tried it)
Move resolved bugs to CLOSED after 5.7 release