Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I use Cygwin to connect a linux box (ubuntu server 12.04) via SSH, and I use X11 forwarding. Every time I ssh, I can use X forwarding for a while then it stops working (eg. gvim says Display cannot be opened). If I exit and re-ssh, it starts working again. And stops again after a while.

Any ideas?

share|improve this question
1  
Does it only stop after a period of inactivity? Does it stop after the same amount of time? Is it possible that the SSH connection was dropped by one of the machines? –  Breakthrough Aug 16 '12 at 19:10
    
apparently it was stopping after the same amount of time.. –  sencer Aug 18 '12 at 4:44

2 Answers 2

up vote 7 down vote accepted

When I had this problem I discovered that I needed to add these lines to ~/.ssh/config:

Host *
    ForwardX11Trusted yes

You should modify the * to some sort of host pattern so it's not enabled for every ssh connection.

You may want to change the ForwardX11Timeout option instead. From man ssh_config:

 ForwardX11Timeout
    Specify a timeout for untrusted X11 forwarding using the format
    described in the TIME FORMATS section of sshd_config(5).  X11
    connections received by ssh(1) after this time will be refused.  The
    default is to disable untrusted X11 forwarding after twenty minutes has
    elapsed.

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

    If this option is set to “no”, remote X11 clients will be considered
    untrusted and prevented from stealing or tampering with data belonging
    to trusted X11 clients.  Furthermore, the xauth(1) token used for the
    session will be set to expire after 20 minutes.  Remote clients will
    be refused access after this time.
share|improve this answer
    
thanks, that worked! –  sencer Aug 18 '12 at 4:43

Yep - It's annoying.

Basic's first: create a file named "config" in your /home/.ssh/ folder using your favorite text editor (Gedit, vim, nano or whatever).

Add the lines:

Hostname 192.168.0.5 
ServerAliveInterval 5

That's it. ServerAliveInterval 5 is explained in the man-pages (and of course 192.168.0.5 is just an example address, you need to use the linuxbox's IP address).

share|improve this answer

Your Answer

 
discard

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.