# ssh X11Forward redirects stream to the wrong port



## mfoacs (Oct 8, 2018)

I have been banging my head around this one for days:
I am connecting to a remote FreeBSD 11.2-RELEASE-p4 (GENERIC) from a Linux box.
On the remote machine, sshd has been configured correctly I assume since: 
	
	



```
debug2: X11 forwarding request accepted on channel 0
```
.
Once connected, I check the DISPLAY variable:

```
localhost:10.0
```
I have also a look into the open ports:

```
username      sshd       55532 8  tcp4   127.0.0.1:6010        *:*
```
I then launch `xclock` and the result is: 

```
debug1: client_input_channel_open: ctype x11 rchan 4 win 65536 max 16384
debug1: client_request_x11: request from ::1 22511
debug2: connect localhost port 6000: Connection refused
debug2: connect localhost port 6000: Connection refused
connect localhost port 6000: Connection refused
debug1: failure x11
Error: Can't open display: localhost:10.0
```

Why is sshd redirecting the stream to the port 6000?

Both the client and the remote machine have a running xorg installation.

On the remote machine ssh and xorg have been compiled from sources, then uninstalled and reinstalled from the FreeBSD repository. It makes no difference.

PF is enabled, and I have tried disabling it too. No change.

Google hasn't provided much help either, I have checked and re-checked all configuration files and everything is ok as far as I can tell.
To make matters worse, it had been working until a few days ago, so I really don't understand.

Any ideas, hints, debugging instructions would be much appreciated.


----------



## mfoacs (Oct 10, 2018)

It turns out that I had `export DISPLAY=0` on the local computer messing up things. I removed the setting and everything is now working as expected.


----------



## mfoacs (Dec 7, 2018)

Well, I was wrong, it seems.

After a fresh Install, the problem reappeared but this time I have been unable to find the root cause:

`XIO:  fatal IO error 22 (Invalid argument) on X server "localhost:10.0"
      after 0 requests (0 known processed) with 0 events remaining.`

Any ideas?


----------



## Phishfry (Dec 7, 2018)

Are you running ssh with the -x option?
This is probably a display environment problem like you previously found.
Have you been checking `env` to see what is happening?


----------



## Phishfry (Dec 7, 2018)

This is why I like helping people. I solved one of my ssh problems by reading.
I was losing xforwarding after it was working. Alas sshd_config(5):


> *ForwardX11Trusted*
> If    this option is set to *yes*, remote X11 clients will have    full
> access to the original X11    display.
> 
> ...


20 Minutes, Eureka. That was my minor problem.


----------



## mfoacs (Dec 10, 2018)

Phishfry said:


> Are you running ssh with the -x option?
> This is probably a display environment problem like you previously found.
> Have you been checking `env` to see what is happening?



I have compared the `env` output of the concerned machine with two other working machines but nothing seems out of the ordinary.

I have tried reinstalling xauth, xhost and eliminated all customization from the user's home to no avail. 
Could it be related to a dual head setup? or the Radeonkms driver?


----------

