If you need to start an x window after sudo ing as someone after doing ssh, you may run into permission problems, for example:
ssh -Y A@remote_machine
su B
xclock
it will fail.
To grant such permission, as user A, type:
xauth list
then, copy the whole line. Su to B, and type:
xauth add <paste the line from previous commnad>
then:
xclock (or whatever)