My local machine is linux mint, and remote one is centos 7. I try to open gnome-terminal on remote machine with x-forwarding, and its not working.

When I connect to host in interactive mode

$ ssh -Y centos-host

Then in opened session I can run gnome-terminal and x-forwarding working

$ gnome-terminal 
$ netstat -nltp
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name 
tcp        0      0    *               LISTEN      -
tcp        0      0*               LISTEN      -  

However when I try yo run

$ ssh -Y centos-host gnome-terminal

The window with gnome terminal opened, but no tunnel for X created.

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name 
tcp        0      0    *               LISTEN      -

I have an another linux mint remote machine, and not experienced such problem with it. So, I think something wrong with centos 7.

Please, help.
Thank you.


The reason is that gnome-terminal forks itself into the background. If you run it in your interactive ssh session, you will notice that you get a new command prompt even though the terminal is still open. In the non-interactive case, as soon as this happens, ssh will think the command has terminated and closes the session, including closing the listening X11 socket on the server. Since there are still active X11 connections, ssh doesn't exit immediately, which is why it looks as if the session is still active, however no new X11 connections can be opened.

You used to be able to do this by using gnome-terminal --disable-factory, however this has unfortunately been removed from gnome-terminal at some point. You have two options now:

  • Use another terminal program that doesn't fork into the background, for example xterm
  • Directly after starting gnome-terminal, in the same ssh session run a command that doesn't terminate, for example ssh -Y server 'gnome-terminal; echo Press enter to exit; read'
  • thank a lot, the fork of the gnome-terminal was a problem. I wrote script that runs gnome-terminal and do sleep until he died. now it works fine. – Boris T Jan 22 '17 at 12:48


  • CentOS Linux release 7.6.1810 (Core)
  • /etc/ssh/sshd_config contains:
X11Forwarding yes

The following commnand works for me:

ssh -Y HOST bash -l -c gnome-terminal --display=${DISPLAY} < /dev/null > /dev/null  2>&1 &

The gnome-terminal --disable-factory informed me --disable-factory was no longer supported.

  • Great answer (but I was still able to improve it a bit, ha). Welcome to the site Mike. – kubanczyk Jun 18 '19 at 20:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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