2

I was working with a startup at one point, and they had an awesome setup where they had a headless server that spun up and launched everything without the need for a login or GUI. Then you could VNC into one of server VMs that one server spun up automatically.

I want something similar to this, but I don't need the VMs. Ideal setup would be a headless server that spins up my applications automatically and then I can have users VNC into it via an SSH tunnel and get a GUI on their remote machines to be able to see and use these applications. If I need to use a VM or some other container application, that wouldn't be the end of the world... but I'm trying to keep the server as simple as possible. And to me it seems I should be able to force the server to remain headless until a user remotely logs into it, but I don't know how to do this and I can't find anything useful on Google.

Right now, I can't find a way to setup VNC without the server going into "GUI-mode" and then it won't let me SSH into it until I log into the server locally, so it can launch the startup programs, and this is unacceptable, I can't be logging into the server locally every time the server reboots or loses power. I really don't like the idea of the auto-login either, as I don't plan on keeping the machine at home, and don't want the server logged in when it's "out and about". Any help, links, articles, thoughts, and opinions are greatly appreciated thanks!

1 Answer 1

3

Not being able to ssh into a headless server without logging in on a local conole or GUI seems to me like major issue and should be treated as a separate issue. If you encrypt your home folder you will be unable to use key files without extra steps. Password login should still work.

As for the rest of it, getting a headless server with VNC from boot:

  1. Install a basic GUI of choice
  2. Disable GUI on startup
    • sudo systemctl set-default multi-user.target
  3. Install vnc server of choice
    • vnc4server is default?
    • tightvncserver
    • tigervnc-standalone-server
    • etc
  4. Choose your VNC GUI
    • You can use Gnome or KDE if you want
    • Lower resource GUIs like fluxbox, openbox, xfce, may be preferable.
  5. Configure your ~/.vnc/xstartup for gui/session and any desired applications
    • Your GUI/session of choice may offer various other startup application options.
    • FluxBox uses ~/.fluxbox/startup
    • Gnome, Cinnamon, Mate, etc use the Startup Application menu entry
  6. Start the VNC session on boot with Cron
    1. crontab -e
    2. @reboot vncserver :1 -geometry 1920x1080 to start one on display :1 or port 5901
      • You should be able to use :0 which would be port 5900
      • Add additional -geometry WIDTHxHEIGHT entries for devices you might use. I think there's a maximum of 8 for vnc4server?
      • You can use xrandr -d :1 -s WIDTHxHEIGHT to switch resolution.
1
  • Thank you so much for you insight. These steps are super helpful, and I got it all working! Jun 16, 2020 at 0:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .