29

I'm getting a bizarre error message while using git:

$ git clone git@github.com:Itseez/opencv.git
Cloning into 'opencv'
Warning: Permanently added the RSA host key for IP address '192.30.252.128' to the list of known hosts.
X11 forwarding request failed on channel 0
(...)

I was under the impression that X11 wasn't required for git, so this seemed strange. This clone worked successfully, so this is more of a "warning" issue than an "error" issue, but it seem unsettling. After all, git shouldn't need X11. Any suggestions?

willem
  • 393

2 Answers2

50

Note that to disable ForwardX11 just for github.com you need something like the following in your ~/.ssh/config

Host github.com
    ForwardX11 no

Host *
    ForwardX11 yes

The last two lines assume that in general you /do/ want to forward your X connection. This can cause confusion because the following is WRONG:

ForwardX11 yes

Host github.com
    ForwardX11 no

Which is what I had (and caused me no end of confusion). This is because in .ssh/config, the first setting wins, and isn't overwritten by subsequent customizations.

HTH, Dan.

Dan
  • 601
16

It looks like you have ssh configured to always attempt to use X11 forwarding. The error message is GitHub telling you that you can't do X11 forwarding from their servers.

Look for ForwardX11 yes in ~/.ssh/config or /etc/ssh/ssh_config and set it to no. This will prevent ssh from attempting to use X11 forwarding for every connection.

p8952
  • 660
  • 2
    You can disable FowardX11 just for github.com if you still want to use it for other servers you connect to. – Keith Thompson Jul 15 '16 at 00:04
  • you might want to mention that Dan's answer points out an important addendum to your solution. You don't want to turn off ForwardX11 for all connections - just for your git cloning hosts. – markgalassi Feb 03 '22 at 03:46