PAM_XAUTH(8)
โจ PAM_XAUTH โ okay so like, forwarding xauth keys between users ๐
bestie this is the pam_xauth page from the Linux-PAM Manual and honestly it's giving "quietly saving your entire X session" energy. let's get into it ๐ซถ
๐ธ NAME ๐ธ
pam_xauth โ a PAM module that forwards xauth keys between users. that's it, that's the whole vibe. โจ
๐ฆ SYNOPSIS ๐ฆ
pam_xauth.so [debug] [xauthpath=/path/to/xauth] [systemuser=UID]
[targetuser=UID]
๐ DESCRIPTION ๐
so the pam_xauth PAM module is literally designed to forward xauth keys (which people sometimes call "cookies" ๐ช) between users. no cap.
here's the situation without it: when xauth is enabled and a user hits up the su(1) command to assume somebody else's privileges, that user can't access the original user's X display anymore, because the new user doesn't have the key needed to get in. rude, honestly. pam_xauth fixes this by forwarding the key from the user running su (the source user) to the user whose identity the source user is assuming (the target user) when the session is created โ and then destroying the key when the session is torn down. iconic behavior, truly. ๐ฅ
so for example: when you run su(1) from an xterm session, you'll be able to run X programs without explicitly dealing with the xauth(1) xauth command or ~/.Xauthority files. slay. no more manual key wrangling bestie.
lowkey important: pam_xauth will only forward keys if xauth can list a key connected to the $DISPLAY environment variable. so if it can't find one, no forwarding happens, periodt.
primitive access control is provided by ~/.xauth/export in the invoking user's home directory and ~/.xauth/import in the target user's home directory.
- if a user has a
~/.xauth/importfile, they will only receive cookies from users listed in that file. if there's no~/.xauth/importfile, they'll accept cookies from any other user. generous queen. ๐ - if a user has a
.xauth/exportfile, they will only forward cookies to users listed in that file. if there's no~/.xauth/exportfile and the invoking user is not root, they'll forward cookies to any other user. if there's no~/.xauth/exportfile and the invoking user is root, they will not forward cookies to other users. (root said "absolutely not" ๐)
both the import and export files support wildcards (such as *). and both can be empty, which signifies that no users are allowed. empty file = closed sign on the door, bestie.
๐ OPTIONS ๐
debugโ prints debug information. for when you need to see what's actually going on in there ๐xauthpath=/path/to/xauthโ specify the path to thexauthprogram. by default it's expected in/usr/X11R6/bin/xauth,/usr/bin/xauth, or/usr/bin/X11/xauth.systemuser=UIDโ specify the highest UID which will be assumed to belong to a "system" user.pam_xauthwill refuse to forward credentials to users with a UID less than or equal to this number, except for root and the"targetuser", if specified.targetuser=UIDโ specify a single target UID which is exempt from thesystemusercheck. one (1) special little exception ๐
๐ MODULE TYPES PROVIDED ๐
only the session type is provided. that's the only one on the menu, and she ate. ๐
โญ RETURN VALUES โญ
PAM_BUF_ERRโ memory buffer error. ๐ญPAM_PERM_DENIEDโ permission denied by import/export file. the files said no.PAM_SESSION_ERRโ cannot determine user name, UID, or access the user's home directory.PAM_SUCCESSโ success!! we love to see it โจPAM_USER_UNKNOWNโ user not known. who is she? ๐
๐ง EXAMPLES ๐ง
add the following line to /etc/pam.d/su to forward xauth keys between users when calling su:
session optional pam_xauth.so
literally one line. one. line. that's the whole setup bestie ๐ซถ
๐ฅ IMPLEMENTATION DETAILS ๐ฅ
okay this part is the "iykyk" section, pay attention:
pam_xauth will work only if it is used from a setuid application in which the getuid() call returns the id of the user running the application, and for which PAM can supply the name of the account that the user is attempting to assume. the typical application of this type is su(1). the application must call both pam_open_session() and pam_close_session() with the ruid set to the uid of the calling user and the euid set to root, and must have provided as the PAM_USER item the name of the target user.
pam_xauth calls xauth(1) as the source user to extract the key for $DISPLAY, then calls xauth as the target user to merge the key into a temporary database and later remove the database.
โ ๏ธ and here's the thing bestie: pam_xauth cannot be told to not remove the keys when the session is closed. that's just not an option. it's gonna clean up after itself whether you like it or not ๐
๐ธ FILES ๐ธ
~/.xauth/importโ XXX~/.xauth/exportโ XXX
๐ฆ SEE ALSO ๐ฆ
๐ AUTHOR ๐
pam_xauth was written by Nalin Dahyabhai <nalin@redhat.com>, based on the original version by Michael K. Johnson <johnsonm@redhat.com>. legends, both of them ๐
and that's the whole page, bestie!! this was Linux-PAM, dated 09/27/2026 โ pam_xauth(8), out. go forward those keys and stay hydrated ๐โจ๐
๐ฆ where this page comes from
- arch rolling: pam 1.7.3-1 ยท GPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms