I just upgraded to MacOS Sierra, and I realized that I can't seem to run the "ssh -X" command in the Terminal anymore. It used to launch xterm windows, but now it's like I didn't even put the -X option anymore. It was working absolutely fine right before I updated. Other than going from OS X Yosemite to MacOS Sierra, I didn't change anything else in the setup.
EDIT:
As suggested, this is what I found in the debug logs that might be causing this problem.
debug1: No xauth program. Warning: untrusted X11 forwarding setup failed: xauth key data not generated
Open System Preferences > Security & Privacy > General, then login to ssh in the Terminal. It will give you a warning about 'ssh' with options of Put in trash or Cancel. Hit Cancel then in the System Preferences panel, you will see that ssh is blocked. Hit Open anyway, then it works.
Turn on SSH in the GUI by going to System Preferences > Sharing > Remote Login. Leverage the Commands tab in the JumpCloud Directory Platform to enable SSH across your fleet.
Terminal is a free software application for Mac computers which can be used to make a SSH connection to your server.
I didn't need to reinstall XQuartz, but, based on Matt Widjaja's answer, I came up with a refinement.
sudo vi /etc/ssh/ssh_config
(This is ssh client config, not sshd_config) Host *
entry add (or add where appropriate per-host) XAuthLocation /usr/X11/bin/xauth
(The location of xauth changed in Sierra)ServerAliveInterval 60
(Pings the server every 60 seconds to keep your ssh connection alive)ForwardX11Timeout 596h
(Allows untrusted X11 connections beyond the 20 minute default)No need to restart ssh, except, of course, existing ssh client connections.
It sounds like -Y (trusted X11) would be preferable to untrusted. If you switch over to trusted, the ForwardX11Timeout line can probably be removed.
The ServerAliveInterval line is also an optional preference.
It may also be possible to make these changes in ~/.ssh/config
(the user's config file) but the permissions have to be correct.
EDIT: I removed ForwardX11 and ForwardX11Trusted. They aren't needed and ForwardX11 is less secure and causes problems for git (or other tools using ssh).
I noticed macOS Sierra resetted my X11 settings so that it disabled my xAuth program. To re-enable xAuth on macOS Sierra:
sudo <text editor of your choice> /etc/ssh/sshd_config
X11Forwarding yes
X11DisplayOffset 10
XAuthLocation <path_to_your_xauth>
where mine was in /opt/X11/bin/xauth. This was probably the golden step that explained why reinstalling worked.sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With