Linux – How to get ssh to read the destination’s `.bashrc`

arch linuxbashlinuxssh

I have two Linux computers at work, a desktop and a laptop, running Openssh under Arch Linux. Under my standard logins, I have a customized .bashrc file inside my home folder on both computers.

Here's the question: When I ssh to the desktop, I'm presented with a pretty customized bash (meaning the .bashrc file has been read). When I ssh to the laptop, I'm presented with a plain and gray bash, and I have to manually run exec bash (so it will read my custom .bashrc). Why?

I must have configured something different on one of these computers that's causing the difference, but I can't figure out what. The ssh command I'm running is a simple ssh username@host (with a clean .ssh/config file) in both cases.

Note: There is already a question asking how to use your .bashrc over ssh, I'm not asking that. I just want to know why one of the hosts is using it, but the other isn't.

Best Answer

Does the .bash_profile (or .profile if .bash_profile does not exist) run . .bashrc or source .bashrc at some point? If not, then your .bashrc will not be used when logging in via ssh, as ssh always starts bash as a "login" shell, which never reads .bashrc by default.