I have been playing around with X11 forwarding the past few hours and so far I've managed to forward my desktop pc's X Server to my laptop, using X11VNC as server and X2VNC as client. X2VNC uses Xinerama to provide a dual-screen-like behavior between my laptop and my desktop pc.

It's actually really great!

I know that most Linux systems run Xorg and desktop environments on TTY7.

Therefore I was thinking, is it in any way possible to have the VNC-tunnel tied to it's own TTY?

It would be great to be able to switch forth and back between two TTY's in order to choose which machine to manage. And I would like this approach more than using Xinerama or a GUI.

migrated from serverfault.com Apr 14 '12 at 21:13

This question came from our site for system and network administrators.


I guess this is not really an answer, but it might be a starting point.

I started a bunch of extra X servers using xinit like so;

xinit -- :1 tty3   
xinit -- :2    
xinit -- :3 tty5    
xinit -- :4

It looks like I can even start multiple gnome3 and xfce sessions on different virtual displays

startx -- :2  tty3   
startx -- :3  tty4

And now I can start stuff in those sessions by exporting the DISPLAY var export DISPLAY=:3 and then select it using the Ctrl-Alt-F2, F3 etc

However I have absolutely no idea what I am doing (am I switching DISPLAY, session, console, or tty?), its just pretty cool, as you say... ;-)

[tomh@workstation001 ~]$ export DISPLAY=:4
[tomh@workstation001 ~]$ google-chrome
  • woo. have totally borked my dm. – Tom H Mar 23 '12 at 22:33
  • Hah great tip, I'm gonna play with this tomorrow and see what I can figure out. – martinjlowm Mar 23 '12 at 23:39
  • It really actually is an answer, but like Tom discovered, X session scripts are generally very poorly prepared for the possibility that the same user is physically logged in to multiple X sessions on the same machine. – tripleee Jul 24 '13 at 6:30

I know this is old but:

xinit -e ssh -XYC $HOSTTOSSHTO startx -- :1

The only downside I see is you cannot close the login terminal once the session starts. Move back and forth with CTRL+ALT+F# like other posts mentioned. I do it with my Raspberry Pi all the time, and have done it with servers and such across the internet as well (a little slow). You can also swap out startx with /usr/bin/icewm, openbox, startKDE or whatever.

  • Can you double check the key combo? I wasn't sure about the F# bit. – slm Jan 18 '14 at 21:45
  • Control+Alt+Function keys – user1658800 Feb 5 '14 at 4:25
  • Oh, it's a Function key. OK I usually see them written as Fn, but now that you say it F# makes total sense. Thanks. – slm Feb 5 '14 at 4:26

I seem to have found a proper solution to this.

I created a user specifically for the purpose of connecting to my desktop computer.

Inside the user's ~/.xinitrc on my laptop I have the following line (/home/desktop/.xinitrc):

exec vncviewer is my desktop computer's ip on my network.

In my case I now use Tiger VNC as client and still X11VNC as server on my desktop pc.

Any client will do I guess.

The way it works now is, I enter tty2 through CTRL+ALT+F2, log in as the new desktop user and then initiate x with xinit -- :1. The new x server will start on tty8, since I already have my main xserver running on tty7.

vncviewer runs and successfully connects to my desktop pc, providing the whole screen plus scroll bars should the desktop pc's resolution be greater than my laptop's.

Now I can easily switch between my laptop and my desktop pc with CTRL+ALT+7 and CTRL+ALT+8.

This is the full procedure assuming you use Tiger VNC (the only difference is exec vncviewer x.x.x.x):

  1. Create new user with adduser desktop
  2. The configuration of the new user is ok with the default values, so keep hitting enter till the user is created.
  3. Open /home/desktop/.xinitrc (remember to do so as root unless you are logged in as desktop and also be aware of permissions) and clean out the file (should it have any content) and enter this line: exec vncviewer x.x.x.x
  4. Replace the x.x.x.x with the IP address you wish.
  5. Save the file.
  6. Enter an unused tty using CTRL+ALT+X where X is a number from 1 to 9.
  7. Log in as desktop
  8. Initiate a new X server with xinit -- :1, you may use a different display if :1 is already in use.
  9. You will be sent to the new tty where the X server is started and voilà! Tiger VNC should now be connected to the IP address you chose.

You may run into trouble if you have a desktop environment which automatically starts when you initiate X from any user. So keep that in mind, if things doesn't work the way they are supposed to.

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.