Basically, you have two possibilities.
Option 1: add the script invocation to .bash_profile, and your other stuff in .bashrc (with .bash_profile sourcing .bashrc, assuming you've got something you want in there too). .bash_profile is sourced on login sessions, .bashrc on interactive non-login sessions. But this would also get you console logins and screen session starts, so may not be ideal.
Option 2: add it to .bash_profile or .bashrc with a conditional
Code:
[[ -n $SSH_CLIENT ]] && /path/to/script.sh
(which checks if SSH_CLIENT is a nonzero-length string, and if it is executes the script). This takes advantage of the fact that ssh sessions set a couple variables that interactive logins don't, but the downside is that those variables propagate to child processes, so descendants wouldn't be able to tell.
Combining the two approaches and a little more gives us a complete solution though.
In .bash_profile (or, really, .bashrc would work at this point too):
Code:
[[ -n SSH_CLIENT && -z $SSH_IS_CONNECTED ]] && export SSH_IS_CONNECTED=1 && /path/to/script
This checks if the SSH variables are defined and the SSH_CONNECTED variable isn't. If that's the case, then it sets it, and executes the script. The nonzero SSH_CONNECTED variable propagates with the other ssh vars, so that no longer evaluates true even if you source .bash_login again (eg: invoking screen).