Whenever I use ssh, after I type the password, xQuartz pop ups in the dock and terminal window looses focus. This happens even if there's no an X session. Why? How to prevent this behavior?

  • Just to clarify - forwarding the X ports over requires using the -X switch within ssh. You want to use the switch in order to use xQuartz within the ssh session, yet retain the focus on the terminal window until you actually do so?
    – Scot
    May 17, 2013 at 19:54
  • I just want a normal command line access, not x window session. I didn't use -X. For example: ssh [email protected]
    – Rnhmjoj
    May 17, 2013 at 20:06
  • Odd. Is there any alias or anything that may be mapped to your ssh command?
    – Scot
    May 17, 2013 at 20:08
  • I don't think. There is nothing that I added to ssh in .profile or .bashrc.
    – Rnhmjoj
    May 17, 2013 at 20:11
  • Do you have anything in your ~/.ssh/config file that may trigger the use of X11? eg, the ForwardX11 option would do it.
    – mjturner
    May 17, 2013 at 21:07

2 Answers 2


Solved by myself. XQuartz installation added a custom configuration for ssh in /etc/ssh/ssh_config (or /etc/ssh_config for older macOS versions). I have just removed ForwardX11 yes and ssh won't open XQuartz anymore.

Below shows the file contents that's causing XQuartz to open.

$ tail -5 /etc/ssh/ssh_config
    SendEnv LANG LC_*

# XAuthLocation added by XQuartz (https://www.xquartz.org)
Host *
    XAuthLocation /opt/X11/bin/xauth
  • The config may also be in ~/.ssh/config as in my case. I forgot that I set it on a per-host config. It looked like this (except comments can't have multiline code blocks?): ForwardX11Trusted yes ForwardX11 yes XAuthLocation <blah> Mar 17 at 19:39

As alluded to by mjturner in the comments, the actual answer to this is to ensure the following is in your /etc/ssh/ssh_config and ~/.ssh/config file:

ForwardX11 no

If set to yes, XQuartz will simply re-add its settings to /etc/ssh/ssh_config

  • This reads as if if the /etc/ssh/ssh_config file gets updated. Is this really the case?
    – nohillside
    Jan 30, 2023 at 16:22
  • Yes, if you comment out the lines in the accepted answer in MACOS 10.11, they will be reinstated if ForwardX11 is yes
    – racitup
    Jan 31, 2023 at 17:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .