Saturday, January 29, 2011

Create/rebuild a new .Xauthority file

This document describes the procedure for rebuilding a /$HOME/.Xauthority file. The information in this document applies to AIX 5.1 and higher.

If you get an MIT magic cookie error when trying to gain remote access the CDE or Xdm, you may be able to solve the problem by rebuilding the .Xauthority file in the home directory of the user trying to log in.

Follow these steps to create a /$HOME/.Xauthority file.

Log in as user and confirm that you are in the user's home directory.

Rename the existing .Xauthority file by running the following command

mv .Xauthority old.Xauthority

Generate a new .Xauthority file by running the following command:

xauth generate :0 . trusted

At the command line, create a new magic-cookie key by entering the following:

randomkey=`/usr/bin/ksh -c 'echo $(( $RANDOM * $RANDOM * 2 ))'`

Add a new entry for another server by running the following command:

xauth add ${HOST}:0 . $randomkey

To view a listing of the .Xauthority file, enter the following

xauth list

1 comment:

  1. According to the man xauth, the magic-cookie key should be 128 bits encoded as 32 hex characters. You could more easily use the following:

    touch ~/.Xauthority
    xauth generate :0 . trusted
    xauth add ${HOST}:0 . `xxd -l 16 -p /dev/urandom`