Kind of a hack, but this sort of works. I say sort of works because there are two places to set the title of the tab if you look in the tab inpector. I wasn't able to set the input I wanted that says "Tab Title" with applescript, but I was able to set the one that says "Window Title." This solution will help me know what machine I'm connected to though.
settabname.sh
#!/bin/bash
osascript -e 'delay 2' -e "tell application \"Terminal\" to tell window 1 to set custom title to \"$1\""
~/.ssh/config
Host *
PermitLocalCommand yes
Host CustName01
LocalCommand ~/.ssh/settabname.sh CustName01 &
HostName ec2-20-12-130-143.compute-1.amazonaws.com
IdentityFile ~/.ssh/remote.pem
User root
The trick here is that & makes the bash with the embedded applescript execute asynchronously. The applescript has a delay which allows it to rename the tab after your remote connection does a rename.
Here's how you can clean up the tab name after the ssh command exits. http://unix.stackexchange.com/questions/40899/ssh-localcommand-on-exithttps://unix.stackexchange.com/questions/40899/ssh-localcommand-on-exit
~/.bashrc
## run a cleanup command after ssh exit
ssh() {
if command ssh "$@"; then
# commands go here
~/.ssh/settabname.sh Local &
fi
}