This is a guide on setting up a headless Sunshine game streaming server on Ubuntu server 22.04 with no physical display attached. For this guide you will need root or have sudo permissions.
First lets install the prerequisite packages.
- Install the ubuntu desktop meta package using
sudo apt-get install ubuntu-desktop
- Install the Nvidia driver and cuda tool kit using the instructions at this link.
- Download the Sunshine Ubuntu 22.04 release from here
- install it with this command
sudo apt install -f ./sunshine-ubuntu-22.04-amd64.deb
- reboot your system
Patching the Nvidia driver
Download the Nvidia driver patcher from here to patch in Nvidia frame buffer copy.
Next lets configure the desktop environment.
- Start be editing the gdm config file to disable wayland and autolog in the user you want to access remotely.
uncomment the WaylandEnable=false line
as well as these two lines. Replace user with the username of who you want to auto login
AutomaticLoginEnable = true
AutomaticLogin = user
- Switch to the home of the user you set to autologin and edit the pipewire config file to unload bluetooth driver, if you don’t do this pipewire will fail to autostart and sunshine will crash when you try to connect as it will be unable to create an audio sink
vi ~/.config/pulse/default.pa to include
###unload driver modules for Bluetooth hardware
- Create an edid file to fake a connected display. This file should be in the user you set to autologin home directory.
A sample edid that supports up to 1080p60can be downloaded from here
- Setting up an Xorg config file
run nvidia-xconfig to create an Xorg config file
then edit it with
Replace the screen section with this, where edid path is the full path to the edid file.
Option “AllowEmptyInitialConfiguration” “True”
Option “UseDisplayDevice” “DP-0”
Option “CustomEDID” “DP-0:Edid Path”
Option “ConnectedMonitor” “DP-0”
Next create a udev rule to allow sunshine to create input devices.
echo ‘KERNEL==“uinput”, SUBSYSTEM==“misc”, OPTIONS+=“static_node=uinput”, TAG+=“uaccess”’ |
sudo tee /etc/udev/rules.d/85-sunshine.rules
Opening ports in the firewall
you need to open these ports to allow you to connect to sunshine
ufw allow 47984/tcp
ufw allow 47989/tcp
ufw allow 48010/tcp
ufw allow 47998/udp
ufw allow 47999/udp
ufw allow 48000/udp
ufw allow 48002/udp
ufw allow 48010/udp
First in the home directory of the user you have set to autologin you’ll need to make the required directory for systemd user services
Next make the systemd service file. This file is set to start pulseaudio if its not running and only start sunshine after pulseaudio has started.
Description=Sunshine is a self-hosted game stream host for Moonlight.
Reload the systemctl daemon so you can use the new service file you created.
systemctl --user daemon-reload
Set sunshine to start at boot
systemctl --user enable Sunshine.service
Set systemctl to start the graphical target, so the desktop environment is started on boot
systemctl set-default graphical.target
Now reboot your machine, sunshine should be up and running but it still needs to be configured. You can check its status with
systemctl --user status Sunshine
The Sunshine docs cover this pretty well. Sunshines autoconfig should work fine, but you still need to access the webui for it to pair the client. The webui is only accessible from the host running sunshine on port 47990. You can access this port over ssh using port forwarding with
ssh -L 47990:localhost:47990 -C -l user@remotemachine
The go to http://localhost:47990 and follow the set up directions.
Congrats Sunshine should now be installed and fully operational