You are hereX11 forwarding with ssh to a system with AFP/CIFS home directories (xauth fails)

X11 forwarding with ssh to a system with AFP/CIFS home directories (xauth fails)


By thomas - Posted on 13 April 2011

I had a user come to me saying they couldn't forward X11 from their home institution to us. I watched them logged in and noticed that xauth was complaining it couldn't lock files. I looked a little deeper and it was that xauth creates a temporary file, then hardlinks to .Xauthority. The problem is that this remote system uses CIFS for home directories (weird huh?). I did some looking and found that ssh has a mechanism to take care of this. The man page has an example script that almost worked for me. I changed it a small amount
XAUTHORITY=/tmp/Xauth-$USER
export XAUTHORITY
alias xauth=$HOME/xauth
if read proto cookie && [ -n "$DISPLAY" ]; then
	if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then
       		# X11UseLocalhost=yes
		echo add `hostname`/unix:`echo $DISPLAY |
		cut -c11-` $proto $cookie
	else
		# X11UseLocalHost=no
		echo add $DISPLAY $proto $cookie
	fi
fi | tee /tmp/ssh.log | xauth -q -
To get this to work properly I made two more changes, I added a script to their home directory called xauth, which just makes sure XAUTHORITY was set and then runs xauth.
#!/bin/sh
 
XAUTHORITY=/tmp/Xauth-mguest20
export XAUTHORITY
exec /usr/bin/xauth $@
To add insult to injury, during the testing of this I had a brain fart and was trying to use $0 instead of $@, lame
user@host: ./xauth add MIT-MAGIC-COOKIE etc
/usr/bin/xauth: (argv):1:  unknown command "./xauth"
:-[

Ok, after that just make sure XAUTHORITY is set properly by the shell (if it is, then the script isn't needed, but just in case...) The user had tcsh (dunno why, religious war I guess, I can't stand csh)

.tcshrc
setenv XAUTHORITY /tmp/Xauth-$USER
alias xauth $HOME/xauth
After that logout, login again and X should start working.

Tags

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <bash>, </bash>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <latex>, </latex>, <sql>, </sql>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo].

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.