Linux "xauth" Command Line Options and Examples
X authority file utility

The xauth program is used to edit and display the authorization information used in connecting to the X server. This program is usually used to extract authorization records from one machine and merge them in on another (as is the case when using remote logins or granting access to other users).


Usage:

xauth [ -f authfile ] [ -vqibn ] [ command arg ... ]




Command Line Options:

-f
This option specifies the name of the authority file to use. By default, xauth will use the filespecified by the XAUTHORITY environment variable or .Xauthority in the user's home directory.
xauth -f ...
-V
COMMANDSThe following commands may be used to manipulate authority files:add displayname protocolname hexkeyAn authorization entry for the indicated display using the given protocol and key data is added to theauthorization file. The data is specified as an even-lengthed string of hexadecimal digits, each pairrepresenting one octet. The first digit of each pair gives the most significant 4 bits of the octet,and the second digit of the pair gives the least significant 4 bits. For example, a 32 characterhexkey would represent a 128-bit value. A protocol name consisting of just a single period is treatedas an abbreviation for MIT-MAGIC-COOKIE-1.generate displayname protocolname [trusted|untrusted][timeout seconds] [group group-id] [data hexdata]This command is similar to add. The main difference is that instead of requiring the user to supplythe key data, it connects to the server specified in displayname and uses the SECURITY extension inorder to get the key data to store in the authorization file. If the server cannot be contacted or ifit does not support the SECURITY extension, the command fails. Otherwise, an authorization entry forthe indicated display using the given protocol is added to the authorization file. A protocol nameconsisting of just a single period is treated as an abbreviation for MIT-MAGIC-COOKIE-1.If the trusted option is used, clients that connect using this authorization will have full run of thedisplay, as usual. If untrusted is used, clients that connect using this authorization will be con‐sidered untrusted and prevented from stealing or tampering with data belonging to trusted clients.See the SECURITY extension specification for full details on the restrictions imposed on untrustedclients. The default is untrusted.The timeout option specifies how long in seconds this authorization will be valid. If the authoriza‐tion remains unused (no clients are connected with it) for longer than this time period, the serverpurges the authorization, and future attempts to connect using it will fail. Note that the purgingdone by the server does not delete the authorization entry from the authorization file. The defaulttimeout is 60 seconds.The group option specifies the application group that clients connecting with this authorizationshould belong to. See the application group extension specification for more details. The default isto not belong to an application group.The data option specifies data that the server should use to generate the authorization. Note thatthis is not the same data that gets written to the authorization file. The interpretation of thisdata depends on the authorization protocol. The hexdata is in the same format as the hexkey describedin the add command. The default is to send no data.[n]extract filename displayname...Authorization entries for each of the specified displays are written to the indicated file. If thenextract command is used, the entries are written in a numeric format suitable for non-binary trans‐mission (such as secure electronic mail). The extracted entries can be read back in using the mergeand nmerge commands. If the filename consists of just a single dash, the entries will be written tothe standard output.[n]list [displayname...]Authorization entries for each of the specified displays (or all if no displays are named) are printedon the standard output. If the nlist command is used, entries will be shown in the numeric formatused by the nextract command; otherwise, they are shown in a textual format. Key data is always dis‐played in the hexadecimal format given in the description of the add command.[n]merge [filename...]Authorization entries are read from the specified files and are merged into the authorization data‐base, superseding any matching existing entries. If the nmerge command is used, the numeric formatgiven in the description of the extract command is used. If a filename consists of just a singledash, the standard input will be read if it hasn't been read before.remove displayname...Authorization entries matching the specified displays are removed from the authority file.source filenameThe specified file is treated as a script containing xauth commands to execute. Blank lines and linesbeginning with a sharp sign (#) are ignored. A single dash may be used to indicate the standardinput, if it hasn't already been read.info Information describing the authorization file, whether or not any changes have been made, and fromwhere xauth commands are being read is printed on the standard output.exit If any modifications have been made, the authority file is written out (if allowed), and the programexits. An end of file is treated as an implicit exit command.quit The program exits, ignoring any modifications. This may also be accomplished by pressing the inter‐rupt character.version This command shows the version number of the xauth executable.help [string]A description of all commands that begin with the given string (or all commands if no string is given)is printed on the standard output.? A short list of the valid commands is printed on the standard output.DISPLAY NAMESDisplay names for the add, [n]extract, [n]list, [n]merge, and remove commands use the same format as the DIS‐PLAY environment variable and the common -display command line argument. Display-specific information (suchas the screen number) is unnecessary and will be ignored. Same-machine connections (such as local-host sock‐ets, shared memory, and the Internet Protocol hostname localhost) are referred to as hostname/unix:displaynum‐ber so that local entries for different machines may be stored in one authority file.EXAMPLEThe most common use for xauth is to extract the entry for the current display, copy it to another machine, andmerge it into the user's authority file on the remote machine:% xauth extract - $DISPLAY | ssh otherhost xauth merge -The following command contacts the server :0 to create an authorization using the MIT-MAGIC-COOKIE-1 protocol.Clients that connect with this authorization will be untrusted.% xauth generate :0 .ENVIRONMENTThis xauth program uses the following environment variables:XAUTHORITYto get the name of the authority file to use if the -f option isn't used.HOME to get the user's home directory if XAUTHORITY isn't defined.FILES$HOME/.Xauthoritydefault authority file if XAUTHORITY isn't defined.
xauth -V ...