# man > xauth(1)

> **TLDR:** Edit and display the authorization information used in connecting to the X server.
>
- Start interactive mode with a specific authority file (defaults to `~/.Xauthority`):
  `xauth -f {{path/to/file}}`
- Display information about the authority file:
  `xauth info`
- Display authorization entries for all the displays:
  `xauth list`
- Add an authorization for a specific display:
  `xauth add {{display_name}} {{protocol_name}} {{key}}`
- Remove the authorization for a specific display:
  `xauth remove {{display_name}}`
- Print the authorization entry for the current display to `stdout`:
  `xauth extract - $DISPLAY`
- Merge the authorization entries from a specific file into the authorization database:
  `cat {{path/to/file}} | xauth merge -`
- Display help:
  `xauth --help`

*Source: tldr-pages*

---

[_XAUTH_(1)](https://www.chedong.com/phpMan.php/man/XAUTH/1/markdown)                               General Commands Manual                              [_XAUTH_(1)](https://www.chedong.com/phpMan.php/man/XAUTH/1/markdown)

## NAME
       xauth - X authority file utility

## SYNOPSIS
       **xauth **[ **-f _**authfile_ ] [ **-vqibn **] [ _command_ _arg_ _..._ ]

## DESCRIPTION
       The  _xauth_ program is used to edit and display the authorization information used in connect‐
       ing 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 ac‐
       cess  to other users).  Commands (described below) may be entered interactively, on the _xauth_
       command line, or in scripts.  Note that this program does **not **contact  the  X  server  except
       when  the  generate command is used.  Normally _xauth_ is not used to create the authority file
       entry in the first place; the program that starts the X server (often  _xdm_  or  _startx_)  does
       that.

## OPTIONS
       The  following  options may be used with _xauth_.  They may be given individually (e.g., _-q_ _-i_)
       or may combined (e.g., _-qi_).

### -f _
               This option specifies the name of the authority file to use.  By default, _xauth_  will
               use  the  file specified by the XAUTHORITY environment variable or _.Xauthority_ in the
               user's home directory.

### -q      
               status  messages.   This  is  the default if an _xauth_ command is given on the command
               line or if the standard output is not directed to a terminal.

### -v      
               indicating  the  results of various operations (e.g., how many records have been read
               in or written out).  This is the default if _xauth_ is reading commands from its  stan‐
               dard input and its standard output is directed to a terminal.

### -i      
               _xauth_ will refuse to read or edit any authority files that have been locked by  other
               programs (usually _xdm_ or another _xauth_).

### -b      
               fore proceeding.  Use this option only to clean up stale locks.

### -n      
               should simply always print the host address as stored in the authority file.

### -V      

## COMMANDS
       The following commands may be used to manipulate authority files:

       **add _**displayname_ _protocolname_ _hexkey_
               An authorization entry for the indicated display using the  given  protocol  and  key
               data  is  added to the authorization file.  The data is specified as an even-lengthed
               string of hexadecimal digits, each pair representing 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 character hexkey would
               represent a 128-bit value.  A protocol name consisting of just  a  single  period  is
               treated as 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  supply the key data, it connects to the server specified in _displayname_ and
               uses the SECURITY extension in order to get the key data to store in  the  authoriza‐
               tion  file.  If the server cannot be contacted or if it does not support the SECURITY
               extension, the command fails.  Otherwise, an authorization entry  for  the  indicated
               display using the given protocol is added to the authorization file.  A protocol name
               consisting  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 the display, as usual.  If **untrusted **is used, clients that connect
               using this authorization will be considered untrusted and prevented from stealing  or
               tampering  with data belonging to trusted clients.  See the SECURITY extension speci‐
               fication for full details on the restrictions imposed on untrusted clients.  The  de‐
               fault is **untrusted**.

               The  **timeout  **option  specifies how long in seconds this authorization will be valid.
               If the authorization remains unused (no clients are connected  with  it)  for  longer
               than  this  time  period, the server purges the authorization, and future attempts to
               connect using it will fail.  Note that the purging done by the server does **not **delete
               the authorization entry from the authorization file.  The default timeout is 60  sec‐
               onds.

               The  **group  **option  specifies the application group that clients connecting with this
               authorization should belong to.  See the application  group  extension  specification
               for more details.  The default is to not belong to an application group.

               The  **data **option specifies data that the server should use to generate the authoriza‐
               tion.  Note that this is **not **the same data that gets  written  to  the  authorization
               file.   The  interpretation  of this data depends on the authorization protocol.  The
               _hexdata_ is in the same format as the _hexkey_ described in the add  command.   The  de‐
               fault is to send no data.


       **[n]extract _**filename_ _displayname..._
               Authorization entries for each of the specified displays are written to the indicated
               file.   If  the _nextract_ command is used, the entries are written in a numeric format
               suitable for non-binary transmission (such as secure electronic mail).  The extracted
               entries can be read back in using the _merge_ and _nmerge_  commands.   If  the  filename
               consists of just a single dash, the entries will be written to the standard output.

       **[n]list **[_displayname_...]
               Authorization  entries  for each of the specified displays (or all if no displays are
               named) are printed on the standard output.  If the _nlist_  command  is  used,  entries
               will be shown in the numeric format used by the _nextract_ command; otherwise, they are
               shown  in  a  textual format.  Key data is always displayed 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  au‐
               thorization  database,  superseding any matching existing entries. If the _nmerge_ com‐
               mand is used, the numeric format given in the description of the _extract_  command  is
               used.   If a filename consists of just a single dash, 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 _**filename_
               The  specified  file  is  treated  as  a script containing _xauth_ commands to execute.
               Blank lines and lines beginning with a sharp sign (#) are ignored.  A single dash may
               be used to indicate the standard input, if it hasn't already been read.

       **info    **Information describing the authorization file, whether or not any changes  have  been
               made, and from where _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 program exits.  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 interrupt 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 NAMES
       Display  names  for  the _add_, _[n]extract_, _[n]list_, _[n]merge_, and _remove_ commands use the same
       format as the DISPLAY environment variable and the common  _-display_  command  line  argument.
       Display-specific  information (such as the screen number) is unnecessary and will be ignored.
       Same-machine connections (such as local-host sockets, shared memory, and the Internet  Proto‐
       col  hostname _localhost_) are referred to as _hostname_/unix:_displaynumber_ so that local entries
       for different machines may be stored in one authority file.

## EXAMPLE
       The most common use for _xauth_ is to extract the entry for the current display, copy it to an‐
       other machine, and merge 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 .

## ENVIRONMENT
       This _xauth_ program uses the following environment variables:

       **XAUTHORITY**
               to 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/.Xauthority_
               default authority file if XAUTHORITY isn't defined.

## SEE ALSO
       [X(7)](https://www.chedong.com/phpMan.php/man/X/7/markdown), [Xsecurity(7)](https://www.chedong.com/phpMan.php/man/Xsecurity/7/markdown), [xhost(1)](https://www.chedong.com/phpMan.php/man/xhost/1/markdown), [Xserver(1)](https://www.chedong.com/phpMan.php/man/Xserver/1/markdown), [xdm(1)](https://www.chedong.com/phpMan.php/man/xdm/1/markdown), [startx(1)](https://www.chedong.com/phpMan.php/man/startx/1/markdown), [Xau(3)](https://www.chedong.com/phpMan.php/man/Xau/3/markdown).

## BUGS
       Users  that have insecure networks should take care to use encrypted file transfer mechanisms
       to copy authorization entries between machines.  Similarly, the  _MIT-MAGIC-COOKIE-1_  protocol
       is  not  very useful in insecure environments.  Sites that are interested in additional secu‐
       rity may need to use encrypted authorization mechanisms such as Kerberos.

       Spaces are currently not allowed in the protocol name.  Quoting could be added for the  truly
       perverse.

## AUTHOR
       Jim Fulton, MIT X Consortium

X Version 11                                 xauth 1.1.2                                    [_XAUTH_(1)](https://www.chedong.com/phpMan.php/man/XAUTH/1/markdown)
