First you need to get your back to my mac account number. In terminal type the following:

dns-sd -E
The final nine digit number is your account number.
Make sure remote login is enabled in system prefs on the target computer.
To ssh in type the following:
ssh -2 -6 username@computer-name.[account number].members.btmm.icloud.com  If you don’t want to hard code your Back To My Mac address into your .ssh/config you can get it dynamically using this line:

echo show Setup:/Network/BackToMyMac | scutil | sed -n 's/.* : *\(.*\).$/\1/p'

 Another way to SSH into another Mac using iCloud’s IPv6 network: in Terminal, choose ‘New Remote Connection’ from the Shell menu, or whack ⇧ + ⌘ + K.