Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the difference between ssh -Y (trusted X11 forwarding) and ssh -X (untrusted X11 forwarding)? As far as I have understood it, it has something to do with security, but I did not grasp the difference and when to use which.

share|improve this question
up vote 50 down vote accepted

Both options have something to do with X11 forwarding. This means if you enable this you can use a graphical client through your SSH session (i.e. use Firefox or something else).

If you use ssh -X remotemachine the remote machine is treated as an untrusted client. So your local client sends a command to the remote machine and receives the graphical output. If your command violates some security settings you'll receive an error instead.

But if you use ssh -Y remotemachine the remote machine is treated as trusted client. This last option can open security problems. Because other graphical (X11) client could sniff data from the remote machine (make screenshots, do keylogging and other nasty stuff) and it is even possible to alter those data.

If you want to know more about those things I suggest reading the Xsecurity manpage or the X Security extension spec. Furthermore you can check the options ForwardX11 and ForwardX11Trusted in your /etc/ssh/ssh_config.

share|improve this answer
The ssh manpage uses unfortunate wording, suggesting (at least to me) that -X is unsafe to use and -Y is better. So thank you for this answer. – Torsten Bronger Sep 9 '14 at 7:08
So, with -X is it impossible for other clients to sniff or alter data? – musiphil Nov 18 '14 at 0:44
So why would one want to use -Y instead of -X in general? – Wernight Jan 5 at 13:56
I have the same question (why to use -Y) and the only case that I understood this may be useful is when the security control on the server side is somehow not implemented/not compatible. I have also read that forwarding X11 is generally a powerful and dangerous tool that should be treated as such. – MakisH Jan 24 at 0:02

Yes. -Y is for trusted X11 forwarding, while -X is for untrusted X11 forwarding. X11 forwarding just allows you to use X11 (i.e. graphical) applications over an SSH session.

I'm not sure what the meaningful difference is between trusted and untrusted X11 connections, but I'm sure it has to do with the server-side configuration (i.e. ssh-config, sshd-config, etc.). Check with your server or network admin about which flag to use.

share|improve this answer
Both computer are my private ones, so there is network admin I could ask. But I guess it is "trusted" then, therefore I could use -Y I guess. – Martin Ueding Apr 16 '11 at 20:11
I don't have enough rep to downvote, so I have to say: This answer contributes nothing whatsoever. – underscore_d Sep 24 '15 at 17:22

If you use the -X option:

-X   Enables X11 forwarding.  This can also be specified on a per-host
     basis in a configuration file.

     X11 forwarding should be enabled with caution.  Users with the
     ability to bypass file permissions on the remote host (for the
     user's X authorization database) can access the local X11 display
     through the forwarded connection.  An attacker may then be able
     to perform activities such as keystroke monitoring.

     For this reason, X11 forwarding is subjected to X11 SECURITY
     extension restrictions by default.  Please refer to the ssh -Y
     option and the ForwardX11Trusted directive in ssh_config(5) for
     more information.

You will have a risk of SSH agent forwarding. The -X option allows a chain of ssh connections to forward key challenges back to the original agent, obviating the need for passwords or private keys on any intermediate machines. A program with root account, on an intermediate machine, can copy the ssh private key and make connections with it.

-Y      Enables trusted X11 forwarding.  Trusted X11 forwardings are not
        subjected to the X11 SECURITY extension controls.

The option -Y, corresponding to the ForwardX11Trusted directive in ssh_config(5), is even less secure because, it removes X11 SECURITY extension controls.

It's more secure to use -x

-x   Disables X11 forwarding.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.