x11 forwarding not working

user_h asked:

I’m having trouble getting x11 forwarding when I ssh into a linux machine from a MAC operating Mojave. When I do ssh -X [email protected], I get the following error appearing after I successfully login: /usr/bin/xauth: error in locking authority file /home/username/.Xauthority . I have tried to follow the fixes suggested to this problem on stackoverflow but they don’t seem to work.

I have tried editing ~/.ssh/config so that it looks like this:

Host *
    XAuthLocation /opt/X11/bin/xauth

This does not fix the problem. Any ideas would be greatly appreciated.

My answer:

Obviously you should remove the change you made to $HOME/.ssh/config. It doesn’t work, and never will, because the path is wrong, and that takes place on the server side anyway.

After that, you should ssh to the server and delete the existing $HOME/.Xauthority file. Then log out, and ssh back in.

This error occurs because the file could not be locked, and that is usually also because it could not be written. So if the problem persists, check the permissions of your home directory on the server.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.