Fixing slow login when using X-forwarding in SSH on OS X 10.6.3
- June 21st, 2010
- Posted in Computers
- Write comment
After upgrading to OS X 10.6.3 I started having some really strange issues when trying to log into Linux or FreeBSD boxes. When I would run the command it would hang for about a minute or two after I typed in the password. When running in verbose mode I saw it was hanging at the xauth command.
$ ssh -vvvY tst-srv ........................ tstuser@tst-srv's password: debug3: packet_send2: adding 48 (len 62 padlen 18 extra_pad 64) debug2: we sent a password packet, wait for reply debug1: Authentication succeeded (password). debug1: channel 0: new [client-session] debug3: ssh_session2_open: channel_new: 0 debug2: channel 0: send open debug1: Entering interactive session. debug2: callback start debug2: x11_get_proto: /usr/X11R6/bin/xauth list /tmp/launch-n3zZuC/org.x:0 2>/dev/null
Looking around the internet I found very little about this problem. Most things I found had to do with people playing around with DNS resolution. I was sure this was not the case for me because I have all the machines I access regularly hard-coded in my /etc/hosts to prevent dealing with DNS.
After a while I came across this post on one of the Apple message boards. Looks like after the 10.6.3 upgrade something changed with xauth. Well, to be more precise, looks like something changed with the entire Xorg toolset.
When I try to check which file xauth is using I am seeing something like this:
$ echo $DISPLAY /tmp/launch-gLkgC0/org.x:0
What seems to be causing some problems is the “org.x” part. Seems like xauth is trying to do is resolve “org.x”, timing out and then moving right along. This is horrible and I have no clue how this made it out into a GA release.
Well, this seems easy enough to fix though once I found the solution. I am running BASH on my system so this is going to be BASH specific. All I did was add the following to my ~/.profile file.
# Fix the X timeout problem DISPLAYLOC=`echo $DISPLAY | sed -e 's/org.x:0//'` if [ ! -e $DISPLAYLOC":0" ]; then ln -s $DISPLAYLOC"org.x:0" $DISPLAYLOC":0" fi DISPLAY=$DISPLAYLOC":0"
What this is doing is creating a symlink to the file that should already exist but has the wonky name to it and making it better formatted. After that it is reseting the DISPLAY variable to something without “org.x”.
I had to close the shell and reopen it to take the new settings the now the timeout is gone!
Wow. Thanks. I had also the target IP in /etc/hosts, so this actually help me. It’s kind of weird. Is it reported as an error in OS X 10.6.3?
Yup, Apple knows about this. There are a couple of duplicate bugs about this. No clue when they’ll do anything about it.
You are a hero! thanks for figuring this out.
I like this solution, except two issues that Im having. One, cshell at least can’t find :0.0 in the if ! -e statement. Basically, that statement always returns true, and thus it tries to redo the link, which already exists, and this it writes an annoying message to the screen. Second, for some reason when using this, when I open X11 for the first time, a terminal doesn’t pop up. I have to manually open a new one via command-n.
Dave,
The commands I have are for bash. If you’re using csh it would look something more like this:
set DISPLAYLOC=`echo $DISPLAY | sed -e ‘s/org.x:0//’`
if ( ! -e $DISPLAYLOC”:0″ )
ln -s $DISPLAYLOC”org.x:0″ $DISPLAYLOC”:0″
endif
setenv DISPLAY $DISPLAYLOC”:0″
My csh is very rusty so there might be errors in that.