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

$ git clone [email protected]:Itseez/opencv.git
Cloning into 'opencv'
Warning: Permanently added the RSA host key for IP address '' 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?


2 Answers 2


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.

  • 3
    Many thanks for "the first setting wins"! Pulled my hair over that especially as swapping the 2 sections from your correct example also does not work!
    – Flamefire
    Aug 17, 2018 at 8:14
  • For other git newbies: you can get the remote URL with git remote -v Jun 14, 2022 at 7:41
  • The order does matter. I had the wildcard first and had this problem. Putting github.com first works.
    – bhundven
    Mar 10, 2023 at 3:37

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.

  • 2
    You can disable FowardX11 just for github.com if you still want to use it for other servers you connect to. Jul 15, 2016 at 0: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. Feb 3, 2022 at 3:46

You must log in to answer this question.

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