ssh remote command execution quoting
You don't because your sed string doesn't have to be quoted, and in fact, on the remote server, it's not quoted.
What's passed as argument to your ssh command looks like this:
for user in $(/bin/ls -A1 /var/cpanel/users) ; do if grep -q RS=paper /var/cpanel/users/${user}; then sed -i s/^RS=paper_lantern$/RS=x3/ /var/cpanel/users/${user}; fi; done
And it works fine because there are no spaces inside the argument of your sed command.
If you want to pass a sed argument with spaces, you should escape your single quotes like so:
'for user in $(/bin/ls -A1 /var/cpanel/users) ; do if grep -q RS=paper /var/cpanel/users/${user}; then sed -i '\''s/^RS=paper_lantern$/RS=x3/'\'' /var/cpanel/users/${user}; fi; done'
With single quotes, you can't escape single quotes like this: \'
You have to use a trick. You have to close quotes, escape your '
and re-open quotes. ('\''
)