How do I make sure ssh sources .profile
and .bashrc
on login without tty?
I have a Mac (10.6.8) that I'm using for various UNIX-y tasks like hosting git repositories. I have remote login enabled via the System Preferences "Sharing" pane. When I ssh
into the machine, bash
sources ~/.profile
, which I have set up to source my ~/.bashrc
file and set up my MacPorts path. The problem is that when I run ssh
without a tty
, like this:
ssh myhost echo \$PATH
Or run a git
command that essentially uses ssh
in the same way:
git clone ssh://myhost/~/code/myrepo.git
My ~/.profile
file is never sourced, so my $PATH
variable is missing /opt/local
(where MacPorts has installed git
). I am aware that:
- I can configure
git
on my local machine to use/opt/local/bin/git-*
on my remote machine - I wouldn't have this problem if I was forcing a
tty
withssh -t
But I don't want to do either of those. I want my remote machine to source my ~/.profile
file regardless of whether or not I'm logging in w/ a tty.
How do I make that dream a reality?
Also: I checked the behavior on a couple Linux machines (Debian and Fedora), and both systems seem to source the ~/.bashrc
file on login regardless of whether it is a tty
. I was under the impression that BSD and Linux both use the same OpenSSH and bash implementations, so it seems like the difference in behavior might come from differences in /etc
config files?