sufehmi

How to create desktop GUI on headless server (no monitor attached)

Oct 13th, 2021 (edited)
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.84 KB | None | 0 0
  1. # ideally these are all done in a screen/tmux session
  2. sudo su
  3.  
  4. apt-get update ; apt-get install -y xserver-xorg-video-dummy
  5.  
  6. # let's create a fake / virtual display device
  7. echo 'Section "Device"' > /etc/X11/xorg.conf
  8. echo '    Identifier  "Configured Video Device"' >> /etc/X11/xorg.conf
  9. echo '    Driver      "dummy"' >> /etc/X11/xorg.conf
  10. echo 'EndSection' >> /etc/X11/xorg.conf
  11. echo '' >> /etc/X11/xorg.conf
  12. echo 'Section "Monitor"' >> /etc/X11/xorg.conf
  13. echo '    Identifier  "Configured Monitor"' >> /etc/X11/xorg.conf
  14. echo '    HorizSync 31.5-48.5' >> /etc/X11/xorg.conf
  15. echo '    VertRefresh 50-70' >> /etc/X11/xorg.conf
  16. echo 'EndSection' >> /etc/X11/xorg.conf
  17. echo '' >> /etc/X11/xorg.conf
  18. echo 'Section "Screen"' >> /etc/X11/xorg.conf
  19. echo '    Identifier  "Default Screen"' >> /etc/X11/xorg.conf
  20. echo '    Monitor     "Configured Monitor"' >> /etc/X11/xorg.conf
  21. echo '    Device      "Configured Video Device"' >> /etc/X11/xorg.conf
  22. echo '    DefaultDepth 24' >> /etc/X11/xorg.conf
  23. echo '    SubSection "Display"' >> /etc/X11/xorg.conf
  24. echo '    Depth 24' >> /etc/X11/xorg.conf
  25. echo '    Modes "1024x800"' >> /etc/X11/xorg.conf
  26. echo '    EndSubSection' >> /etc/X11/xorg.conf
  27. echo 'EndSection' >> /etc/X11/xorg.conf
  28.  
  29. shutdown -r now
  30.  
  31. # start GUI
  32. startx
  33.  
  34. # open another screen/tmux
  35.  
  36. # install xrdp
  37. # so we can remote screen to X / desktop
  38. apt-get install xrdp
  39. adduser xrdp ssl-cert  
  40.  
  41. nano /etc/xrdp/xrdp.ini
  42.  
  43. # make sure there's this line to ensure secure access to xrdp
  44. # (forcing xrdp to listen to 127.0.0.1 port 3389)
  45. # port=tcp://.:3389
  46.  
  47. systemctl restart xrdp
  48.  
  49.  
  50.  
  51. ##########
  52. # Then you can connect to the GUI by creating an SSH Tunnel to 127.0.0.1 port 3389 on server
  53. #ssh -v -L 3389:localhost:33890 -N    myusername@myserver.com
  54.  
  55.  
  56. # then connect to port 33890 - voila, server's GUI
  57. #rdesktop localhost:33890
  58.  
  59.  
  60.  
Add Comment
Please, Sign In to add comment