I’m working with a lot of remote hosts that are changing a lot. To have a streamlined workflow on all hosts I’m downloading my personal dotfiles with bash aliases, small exes and configurations onto these servers upon login and source the new bash files. For this I have aliased my ssh command to this:
ssh() {
command ssh -t -o RemoteCommand="git -C '/tmp/myuser/dotfiles' pull --rebase
|| git clone https://github.com/MyUser/dotfiles.git '/tmp/myuser/dotfiles';
bash --rcfile '/tmp/myuser/dotfiles/.bashrc' -i" "$@"
}
This worked reliably so far, however the issue here is that this alias sometimes gets in the way. One case is for example if I want to execute a command on the remote host from my local machine without logging into the host:
ssh foreign.host 'curl http://localhost:8888/say/hello'
In that case ssh will complain with Cannot execute command-line and remote command.
(since the remote command is already given).
Is there a way to configure OpenSSh so that only when executing a bash login shell on a host my dotfiles are fetched and sourced?