I was actually trying to learn the basics of X11 via PuTTY last week. I came across a nice tutorial. To be perfectly honest, as this was my first foray into X11, I didn't necessarily absorb all of the info. I did, however, get everything working by following along.
There is a section on this page that dives into creating and configuring those magic cookies and setting up to use Xauth.
On the same page there, it also goes into some detail about Xhost, as @arved mentioned. The relatively short section is quoted below...
Xhost allows access based on hostnames. The server maintains a list of
hosts which are allowed to connect to it. It can also disable host
checking entirely. Beware: this means no checks are done, so every
host may connect!
You can control the server's host list with the xhost program. To use
this mechanism in the previous example, do:
light$ xhost +dark.matt.er This allows all connections from host
dark.matt.er. As soon as your X client has made its connection and
displays a window, for safety, revoke permissions for more connections
light$ xhost -dark.matt.er You can disable host checking with:
light$ xhost + This disables host access checking and thus allows
everyone to connect. You should never do this on a network on which
you don't trust all users (such as Internet). You can re-enable host
light$ xhost - xhost - by itself does not remove all hosts from the
access list (that would be quite useless - you wouldn't be able to
connect from anywhere, not even your local host).
Xhost is a very insecure mechanism. It does not distinguish between
different users on the remote host. Also, hostnames (addresses
actually) can be spoofed. This is bad if you're on an untrusted
network (for instance already with dialup PPP access to Internet).