Dans le cas où le ssh est utilisé pour exécuter une commande, aucun shell de connexion n'est exécuté (et donc le fichier .bashrc n'est pas exécuté) :
man ssh
[...]
If command is specified, it is executed on the remote host instead of a
login shell.
Si tu veux que ce cas soit aussi pris en compte par ton mécanisme de traçage, il y a quelque chose qui est prévu directement dans ssh :
man ssh
[...]
~/.ssh/rc
Commands in this file are executed by ssh when the user logs in,
just before the user's shell (or command) is started. See the
sshd(8) manual page for more information.