diff --git a/setup.py b/setup.py
index 1a04e899363fa269fcdd8e38007e2a55133377a7..28b42130137d5302cea8b3c500c2dee032a46a01 100755
--- a/setup.py
+++ b/setup.py
@@ -116,6 +116,15 @@ def main():
         print('Your system seems to have no networking tool installed. '
               'The proxy magic will not work!')
 
+    # replace xauth file
+    try:
+        xauth_file = subprocess.check_output(['which', 'xauth'])
+        print('xauth determined at {}.'.format(xauth_file.strip()))
+        text = text.replace('/usr/X11/bin/xauth', xauth_file.strip())
+    except subprocess.CalledProcessError as e:
+        print('Could not find xauth. X11-forwarding will not work!')
+        text = text.replace('    XAuthLocation /usr/X11/bin/xauth\n', '')
+
     # update the e5 username
     if E5_USERNAME:
         username = E5_USERNAME