Double quotes or single quotes when using ssh?

I'm not very familiar with the ssh command. When I tried to set a variable and then echo its value on a remote machine via ssh, I found a problem. For example,

$ ITSME=itsme
$ ssh xxx.xxxx.xxx.xxx "ITSME=itsyou; echo $ITSME"
itsme
$ ssh xxx.xxxx.xxx.xxx 'ITSME=itsyou; echo $ITSME'
itsyou
$

So what was going on here? Which satement was executed on remote machine and which one was on local system? I'm a little confused ....

Check the links below.

Double quotes don't prevent variables from being expanded locally. So the remote host sees "ITSME=itsyou; echo itsme" in the first case.

So the two statements: ITSME=itsyou & echo $ITSME are both executed on remote host. But in the case of double quotes, variable will be evaluated first so the argument passed to ssh is actually ITSME=itsyou; echo itsme. While in the case of single quotes, no special characters survive. The argument passed to ssh is ITSME=itsyou; echo $ITSME. Understood, this is really an issue of command-line processing.