The use of sudo complicates things a bit and will require a few extra steps.
If you've setup your /etc/ssh/sshd_config as others have mentioned with
then ssh'n into the box as user2 via
$ ssh -YC remote.example.com
You should be able to run remote X apps as user2. A simple way to test this on a lot of X based systems is to run
It's very lightweight compared to something like firefox though firefox will work as well.
Once you are certain X is working via your remote ssh connection as user2 we can make it work with the sudo to user1. The problem is that when you sudo to user1 you are losing authority to use your remote X forwarding. To get around this, first as user2 do the following after logging in
$ echo $DISPLAY
$ xauth list
carlisle/unix:17 MIT-MAGIC-COOKIE-1 161bda5fc81200a4e74e578009177fb8
You should see a line that contains the same display number, in my example it's 17. You'll want to find the matching number in the xauth list output. Next sudo to user1 and run an xauth add command to add the auth line that matched above
$ sudo su - user1
$ xauth add carlisle/unix:17 MIT-MAGIC-COOKIE-1 161bda5fc81200a4e74e578009177fb8
You should now be able to run any app you want.
$ xlogo # or any X app such as firefox
If you get an error about being unable to lock ~user2/.Xauthority you will need to adjust permissions on that file prior to using sudo to switch to user1. It's not exactly secure but you could set the file permissions to chmod 666 on that file to test.