Documentation Update: Add linux ssh guide (#1527)
Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com>
This commit is contained in:
@@ -6,4 +6,5 @@ ignore_directives =
|
|||||||
doxygenfile,
|
doxygenfile,
|
||||||
include,
|
include,
|
||||||
mdinclude,
|
mdinclude,
|
||||||
|
tab,
|
||||||
todo,
|
todo,
|
||||||
|
|||||||
@@ -5,3 +5,4 @@ rstcheck[sphinx]==6.2.0
|
|||||||
rstfmt==0.0.14
|
rstfmt==0.0.14
|
||||||
Sphinx==7.2.5
|
Sphinx==7.2.5
|
||||||
sphinx-copybutton==0.5.2
|
sphinx-copybutton==0.5.2
|
||||||
|
sphinx_inline_tabs==2023.4.21
|
||||||
|
|||||||
@@ -866,10 +866,10 @@ capture
|
|||||||
or `nvlax <https://github.com/illnyang/nvlax/>`__.
|
or `nvlax <https://github.com/illnyang/nvlax/>`__.
|
||||||
wlr Capture for wlroots based Wayland compositors via DMA-BUF.
|
wlr Capture for wlroots based Wayland compositors via DMA-BUF.
|
||||||
kms DRM/KMS screen capture from the kernel. This requires that sunshine has cap_sys_admin capability.
|
kms DRM/KMS screen capture from the kernel. This requires that sunshine has cap_sys_admin capability.
|
||||||
See :ref:`Linux Setup <about/usage:setup>`.
|
See :ref:`Linux Setup <about/usage:linux>`.
|
||||||
x11 Uses XCB. This is the slowest and most CPU intensive so should be avoided if possible.
|
x11 Uses XCB. This is the slowest and most CPU intensive so should be avoided if possible.
|
||||||
========= ===========
|
========= ===========
|
||||||
|
|
||||||
**Default**
|
**Default**
|
||||||
Automatic. Sunshine will use the first capture method available in the order of the table above.
|
Automatic. Sunshine will use the first capture method available in the order of the table above.
|
||||||
|
|
||||||
@@ -877,7 +877,7 @@ capture
|
|||||||
.. code-block:: text
|
.. code-block:: text
|
||||||
|
|
||||||
capture = kms
|
capture = kms
|
||||||
|
|
||||||
encoder
|
encoder
|
||||||
^^^^^^^
|
^^^^^^^
|
||||||
|
|
||||||
@@ -992,7 +992,7 @@ nvenc_preset
|
|||||||
**Description**
|
**Description**
|
||||||
NVENC encoder performance preset.
|
NVENC encoder performance preset.
|
||||||
Higher numbers improve compression (quality at given bitrate) at the cost of increased encoding latency.
|
Higher numbers improve compression (quality at given bitrate) at the cost of increased encoding latency.
|
||||||
Recommended to change only when limited by network or decoder, otherwise similar effect can be accomplished by increasing bitrate.
|
Recommended to change only when limited by network or decoder, otherwise similar effect can be accomplished by increasing bitrate.
|
||||||
|
|
||||||
.. Note:: This option only applies when using NVENC `encoder`_.
|
.. Note:: This option only applies when using NVENC `encoder`_.
|
||||||
|
|
||||||
@@ -1027,7 +1027,7 @@ nvenc_twopass
|
|||||||
**Description**
|
**Description**
|
||||||
Enable two-pass mode in NVENC encoder.
|
Enable two-pass mode in NVENC encoder.
|
||||||
This allows to detect more motion vectors, better distribute bitrate across the frame and more strictly adhere to bitrate limits.
|
This allows to detect more motion vectors, better distribute bitrate across the frame and more strictly adhere to bitrate limits.
|
||||||
Disabling it is not recommended since this can lead to occasional bitrate overshoot and subsequent packet loss.
|
Disabling it is not recommended since this can lead to occasional bitrate overshoot and subsequent packet loss.
|
||||||
|
|
||||||
.. Note:: This option only applies when using NVENC `encoder`_.
|
.. Note:: This option only applies when using NVENC `encoder`_.
|
||||||
|
|
||||||
@@ -1058,7 +1058,7 @@ nvenc_realtime_hags
|
|||||||
**Description**
|
**Description**
|
||||||
Use realtime gpu scheduling priority in NVENC when hardware accelerated gpu scheduling (HAGS) is enabled in Windows.
|
Use realtime gpu scheduling priority in NVENC when hardware accelerated gpu scheduling (HAGS) is enabled in Windows.
|
||||||
Currently NVIDIA drivers may freeze in encoder when HAGS is enabled, realtime priority is used and VRAM utilization is close to maximum.
|
Currently NVIDIA drivers may freeze in encoder when HAGS is enabled, realtime priority is used and VRAM utilization is close to maximum.
|
||||||
Disabling this option lowers the priority to high, sidestepping the freeze at the cost of reduced capture performance when the GPU is heavily loaded.
|
Disabling this option lowers the priority to high, sidestepping the freeze at the cost of reduced capture performance when the GPU is heavily loaded.
|
||||||
|
|
||||||
.. Note:: This option only applies when using NVENC `encoder`_.
|
.. Note:: This option only applies when using NVENC `encoder`_.
|
||||||
|
|
||||||
|
|||||||
@@ -128,11 +128,53 @@ Changing Resolution and Refresh Rate (Linux - X11)
|
|||||||
+----------------------+---------------------------------------------------------------------------------------------------------------------------------------+
|
+----------------------+---------------------------------------------------------------------------------------------------------------------------------------+
|
||||||
| **Field** | **Value** |
|
| **Field** | **Value** |
|
||||||
+----------------------+---------------------------------------------------------------------------------------------------------------------------------------+
|
+----------------------+---------------------------------------------------------------------------------------------------------------------------------------+
|
||||||
| Command Preparations | Do: ``sh -c "xrandr --output HDMI-1 --mode \"${SUNSHINE_CLIENT_WIDTH}x${SUNSHINE_CLIENT_HEIGHT}\" --range ${SUNSHINE_CLIENT_FPS}"`` |
|
| Command Preparations | Do: ``sh -c "xrandr --output HDMI-1 --mode \"${SUNSHINE_CLIENT_WIDTH}x${SUNSHINE_CLIENT_HEIGHT}\" --rate ${SUNSHINE_CLIENT_FPS}"`` |
|
||||||
| +---------------------------------------------------------------------------------------------------------------------------------------+
|
| +---------------------------------------------------------------------------------------------------------------------------------------+
|
||||||
| | Undo: ``xrandr --output HDMI-1 --mode 3840x2160 --rate 120`` |
|
| | Undo: ``xrandr --output HDMI-1 --mode 3840x2160 --rate 120`` |
|
||||||
+----------------------+---------------------------------------------------------------------------------------------------------------------------------------+
|
+----------------------+---------------------------------------------------------------------------------------------------------------------------------------+
|
||||||
|
|
||||||
|
.. hint::
|
||||||
|
The above only works if the xrandr mode already exists. You will need to create new modes to stream to macOS and iOS devices, since they use non standard resolutions.
|
||||||
|
|
||||||
|
You can update the ``Do`` command to this:
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
bash -c "${HOME}/scripts/set-custom-res.sh \"${SUNSHINE_CLIENT_WIDTH}\" \"${SUNSHINE_CLIENT_HEIGHT}\" \"${SUNSHINE_CLIENT_FPS}\""
|
||||||
|
|
||||||
|
The ``set-custom-res.sh`` will have this content:
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Get params and set any defaults
|
||||||
|
width=${1:-1920}
|
||||||
|
height=${2:-1080}
|
||||||
|
refresh_rate=${3:-60}
|
||||||
|
|
||||||
|
# You may need to adjust the scaling differently so the UI/text isn't too small / big
|
||||||
|
scale=${4:-0.55}
|
||||||
|
|
||||||
|
# Get the name of the active display
|
||||||
|
display_output=$(xrandr | grep " connected" | awk '{ print $1 }')
|
||||||
|
|
||||||
|
# Get the modeline info from the 2nd row in the cvt output
|
||||||
|
modeline=$(cvt ${width} ${height} ${refresh_rate} | awk 'FNR == 2')
|
||||||
|
xrandr_mode_str=${modeline//Modeline \"*\" /}
|
||||||
|
mode_alias="${width}x${height}"
|
||||||
|
|
||||||
|
echo "xrandr setting new mode ${mode_alias} ${xrandr_mode_str}"
|
||||||
|
xrandr --newmode ${mode_alias} ${xrandr_mode_str}
|
||||||
|
xrandr --addmode ${display_output} ${mode_alias}
|
||||||
|
|
||||||
|
# Reset scaling
|
||||||
|
xrandr --output ${display_output} --scale 1
|
||||||
|
|
||||||
|
# Apply new xrandr mode
|
||||||
|
xrandr --output ${display_output} --primary --mode ${mode_alias} --pos 0x0 --rotate normal --scale ${scale}
|
||||||
|
|
||||||
|
# Optional reset your wallpaper to fit to new resolution
|
||||||
|
# xwallpaper --zoom /path/to/wallpaper.png
|
||||||
|
|
||||||
Changing Resolution and Refresh Rate (Linux - Wayland)
|
Changing Resolution and Refresh Rate (Linux - Wayland)
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
10
docs/source/about/guides/guides.rst
Normal file
10
docs/source/about/guides/guides.rst
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
Guides
|
||||||
|
======
|
||||||
|
|
||||||
|
Collection of guides written by the community!
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 2
|
||||||
|
|
||||||
|
app_examples
|
||||||
|
linux/linux
|
||||||
526
docs/source/about/guides/linux/headless_ssh.rst
Normal file
526
docs/source/about/guides/linux/headless_ssh.rst
Normal file
@@ -0,0 +1,526 @@
|
|||||||
|
Remote SSH Headless Setup
|
||||||
|
=========================
|
||||||
|
|
||||||
|
.. csv-table:: Remote SSH Headless Setup
|
||||||
|
:header-rows: 0
|
||||||
|
:stub-columns: 1
|
||||||
|
|
||||||
|
Author, `Eric Dong <https://github.com/e-dong>`__
|
||||||
|
Difficulty, Intermediate
|
||||||
|
|
||||||
|
This is a guide to setup remote SSH into host to startup X server and sunshine without physical login and dummy plug.
|
||||||
|
The virtual display is accelerated by the NVidia GPU using the TwinView configuration.
|
||||||
|
|
||||||
|
.. attention::
|
||||||
|
This guide is specific for Xorg and NVidia GPUs. I start the X server using the ``startx`` command.
|
||||||
|
I also only tested this on an Artix runit init system on LAN.
|
||||||
|
I didn't have to do anything special with pulseaudio (pipewire untested).
|
||||||
|
|
||||||
|
Keep your monitors plugged in until the `Checkpoint`_ step
|
||||||
|
|
||||||
|
.. tip::
|
||||||
|
Prior to editing any system configurations, you should make a copy of the original file.
|
||||||
|
This will allow you to use it for reference or revert your changes easily.
|
||||||
|
|
||||||
|
The Big Picture
|
||||||
|
---------------
|
||||||
|
Once you are done, you will need to perform these 3 steps:
|
||||||
|
|
||||||
|
#. Turn on the host machine
|
||||||
|
#. Start sunshine on remote host with a script that:
|
||||||
|
|
||||||
|
- Edits permissions of ``/dev/uinput`` (added sudo config to execute script with no password prompt)
|
||||||
|
- Starts X server with ``startx`` on virtual display
|
||||||
|
- Starts ``Sunshine``
|
||||||
|
|
||||||
|
#. Startup Moonlight on the client of interest and connect to host
|
||||||
|
|
||||||
|
.. hint::
|
||||||
|
|
||||||
|
As an alternative to SSH...
|
||||||
|
|
||||||
|
**Step 2** can be replaced with autologin and starting sunshine as a service or putting
|
||||||
|
``sunshine &`` in your ``.xinitrc`` file if you start your X server with ``startx``.
|
||||||
|
In this case, the workaround for ``/dev/uinput`` permissions is not needed because the udev rule would be triggered
|
||||||
|
for "physical" login. See :ref:`Linux Setup <about/usage:linux>`. I personally think autologin compromises the
|
||||||
|
security of the PC, so I went with the remote SSH route. I use the PC more than for gaming, so I don't need a
|
||||||
|
virtual display everytime I turn on the PC (E.g running updates, config changes, file/media server).
|
||||||
|
|
||||||
|
First we will setup the host and then the SSH Client (Which may not be the same as the machine running the
|
||||||
|
moonlight client)
|
||||||
|
|
||||||
|
Host Setup
|
||||||
|
----------
|
||||||
|
|
||||||
|
We will be setting up:
|
||||||
|
|
||||||
|
#. `Static IP Setup`_
|
||||||
|
#. `SSH Server Setup`_
|
||||||
|
#. `Virtual Display Setup`_
|
||||||
|
#. `Uinput Permissions Workaround`_
|
||||||
|
#. `Stream Launcher Script`_
|
||||||
|
|
||||||
|
|
||||||
|
Static IP Setup
|
||||||
|
^^^^^^^^^^^^^^^
|
||||||
|
Setup static IP Address for host. For LAN connections you can use DHCP reservation within your assigned range.
|
||||||
|
e.g. 192.168.x.x. This will allow you to ssh to the host consistently, so the assigned IP address does
|
||||||
|
not change. It is preferred to set this through your router config.
|
||||||
|
|
||||||
|
|
||||||
|
SSH Server Setup
|
||||||
|
^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
Most distros have OpenSSH already installed. If it is not present, install OpenSSH using your package manager.
|
||||||
|
|
||||||
|
.. tab:: Debian/Ubuntu
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install openssh-server
|
||||||
|
|
||||||
|
.. tab:: Arch/Artix
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
sudo pacman -S openssh
|
||||||
|
# Install openssh-<other_init> if you are not using SystemD
|
||||||
|
# e.g. sudo pacman -S openssh-runit
|
||||||
|
|
||||||
|
.. tab:: Alpine
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
sudo apk update
|
||||||
|
sudo apk add openssh
|
||||||
|
|
||||||
|
.. tab:: CentOS/RHEL/Fedora
|
||||||
|
|
||||||
|
**CentOS/RHEL 7**
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
sudo yum install openssh-server
|
||||||
|
|
||||||
|
**CentOS/Fedora/RHEL 8**
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
sudo dnf install openssh-server
|
||||||
|
|
||||||
|
Next make sure the OpenSSH daemon is enabled to run when the system starts.
|
||||||
|
|
||||||
|
.. tab:: SystemD
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
sudo systemctl enable sshd.service
|
||||||
|
sudo systemctl start sshd.service # Starts the service now
|
||||||
|
sudo systemctl status sshd.service # See if the service is running
|
||||||
|
|
||||||
|
.. tab:: Runit
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
sudo ln -s /etc/runit/sv/sshd /run/runit/service # Enables the OpenSSH daemon to run when system starts
|
||||||
|
sudo sv start sshd # Starts the service now
|
||||||
|
sudo sv status sshd # See if the service is running
|
||||||
|
|
||||||
|
.. tab:: OpenRC
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
rc-update add sshd # Enables service
|
||||||
|
rc-status # List services to verify sshd is enabled
|
||||||
|
rc-service sshd start # Starts the service now
|
||||||
|
|
||||||
|
**Disabling PAM in sshd**
|
||||||
|
|
||||||
|
I noticed when the ssh session is disconnected for any reason, ``pulseaudio`` would disconnect.
|
||||||
|
This is due to PAM handling sessions. When running ``dmesg``, I noticed ``elogind`` would say removed user session.
|
||||||
|
In this `Gentoo Forums post <https://forums.gentoo.org/viewtopic-t-1090186-start-0.html>`__,
|
||||||
|
someone had a similar issue. Starting the X server in the background and exiting out of the console would cause your
|
||||||
|
session to be removed.
|
||||||
|
|
||||||
|
.. caution::
|
||||||
|
According to this `article <https://devicetests.com/ssh-usepam-security-session-status>`__
|
||||||
|
disabling PAM increases security, but reduces certain functionality in terms of session handling.
|
||||||
|
*Do so at your own risk!*
|
||||||
|
|
||||||
|
Edit the ``sshd_config`` file with the following to disable PAM.
|
||||||
|
|
||||||
|
.. code-block:: text
|
||||||
|
|
||||||
|
usePAM no
|
||||||
|
|
||||||
|
After making changes to the ``sshd_config``, restart the sshd service for changes to take effect.
|
||||||
|
|
||||||
|
.. tip::
|
||||||
|
Run the command to check the ssh configuration prior to restarting the sshd service.
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
sudo sshd -t -f /etc/ssh/sshd_config
|
||||||
|
|
||||||
|
An incorrect configuration will prevent the sshd service from starting, which might mean
|
||||||
|
losing SSH access to the server.
|
||||||
|
|
||||||
|
.. tab:: SystemD
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
sudo systemctl restart sshd.service
|
||||||
|
|
||||||
|
.. tab:: Runit
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
sudo sv restart sshd
|
||||||
|
|
||||||
|
.. tab:: OpenRC
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
sudo rc-service sshd restart
|
||||||
|
|
||||||
|
|
||||||
|
Virtual Display Setup
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
As an alternative to a dummy dongle, you can use this config to create a virtual display.
|
||||||
|
|
||||||
|
.. important::
|
||||||
|
This is only available for NVidia GPUs using Xorg.
|
||||||
|
|
||||||
|
.. hint::
|
||||||
|
Use ``xrandr`` to see name of your active display output. Usually it starts with ``DP`` or ``HDMI``. For me, it is ``DP-0``.
|
||||||
|
Put this name for the ``ConnectedMonitor`` option under the ``Device`` section.
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
xrandr | grep " connected" | awk '{ print $1 }'
|
||||||
|
|
||||||
|
|
||||||
|
.. code-block:: xorg.conf
|
||||||
|
|
||||||
|
Section "ServerLayout"
|
||||||
|
Identifier "TwinLayout"
|
||||||
|
Screen 0 "metaScreen" 0 0
|
||||||
|
EndSection
|
||||||
|
|
||||||
|
Section "Monitor"
|
||||||
|
Identifier "Monitor0"
|
||||||
|
Option "Enable" "true"
|
||||||
|
EndSection
|
||||||
|
|
||||||
|
Section "Device"
|
||||||
|
Identifier "Card0"
|
||||||
|
Driver "nvidia"
|
||||||
|
VendorName "NVIDIA Corporation"
|
||||||
|
Option "MetaModes" "1920x1080"
|
||||||
|
Option "ConnectedMonitor" "DP-0"
|
||||||
|
Option "ModeValidation" "NoDFPNativeResolutionCheck,NoVirtualSizeCheck,NoMaxPClkCheck,NoHorizSyncCheck,NoVertRefreshCheck,NoWidthAlignmentCheck"
|
||||||
|
EndSection
|
||||||
|
|
||||||
|
Section "Screen"
|
||||||
|
Identifier "metaScreen"
|
||||||
|
Device "Card0"
|
||||||
|
Monitor "Monitor0"
|
||||||
|
DefaultDepth 24
|
||||||
|
Option "TwinView" "True"
|
||||||
|
SubSectionSub "Display"
|
||||||
|
Modes "1920x1080"
|
||||||
|
EndSubSection
|
||||||
|
EndSection
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
The ``ConnectedMonitor`` tricks the GPU into thinking a monitor is connected,
|
||||||
|
even if there is none actually connected! This allows a virtual display to be created that is accelerated with
|
||||||
|
your GPU! The ``ModeValidation`` option disables valid resolution checks, so you can choose any
|
||||||
|
resolution on the host!
|
||||||
|
|
||||||
|
**References**
|
||||||
|
|
||||||
|
- `issue comment on virtual-display-linux
|
||||||
|
<https://github.com/dianariyanto/virtual-display-linux/issues/9#issuecomment-786389065>`__
|
||||||
|
- `Nvidia Documentation on Configuring TwinView
|
||||||
|
<https://download.nvidia.com/XFree86/Linux-x86/270.29/README/configtwinview.html>`__
|
||||||
|
- `Arch Wiki Nvidia#TwinView <https://wiki.archlinux.org/title/NVIDIA#TwinView>`__
|
||||||
|
- `Unix Stack Exchange - How to add virtual display monitor with Nvidia proprietary driver
|
||||||
|
<https://unix.stackexchange.com/questions/559918/how-to-add-virtual-monitor-with-nvidia-proprietary-driver>`__
|
||||||
|
|
||||||
|
|
||||||
|
Uinput Permissions Workaround
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
**Steps**
|
||||||
|
|
||||||
|
We can use ``chown`` to change the permissions from a script. Since this requires ``sudo``,
|
||||||
|
we will need to update the sudo configuration to execute this without being prompted for a password.
|
||||||
|
|
||||||
|
#. Create a ``sunshine-setup.sh`` script to update permissions on ``/dev/uinput``. Since we aren't logged into the host,
|
||||||
|
the udev rule doesn't apply.
|
||||||
|
#. Update user sudo configuration ``/etc/sudoers.d/<user>`` to allow the ``sunshine-setup.sh``
|
||||||
|
script to be executed with ``sudo``.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
After I setup the :ref:`udev rule <about/usage:linux>` to get access to ``/dev/uinput``,
|
||||||
|
I noticed when I sshed into the host without physical login, the ACL permissions on ``/dev/uinput`` were not changed.
|
||||||
|
So I asked `reddit
|
||||||
|
<https://www.reddit.com/r/linux_gaming/comments/14htuzv/does_sshing_into_host_trigger_udev_rule_on_the/>`__.
|
||||||
|
I discovered that SSH sessions are not the same as a physical login.
|
||||||
|
I suppose it's not possible for SSH to trigger a udev rule or create a physical login session.
|
||||||
|
|
||||||
|
**Setup Script**
|
||||||
|
|
||||||
|
This script will take care of any precondtions prior to starting up sunshine.
|
||||||
|
|
||||||
|
Run the following to create a script named something like ``sunshine-setup.sh``:
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
echo "chown $(id -un):$(id -gn) /dev/uinput" > sunshine-setup.sh &&\
|
||||||
|
chmod +x sunshine-setup.sh
|
||||||
|
|
||||||
|
(**Optional**) To Ensure ethernet is being used for streaming,
|
||||||
|
you can block WiFi with ``rfkill``.
|
||||||
|
|
||||||
|
Run this command to append the rfkill block command to the script:
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
echo "rfkill block $(rfkill list | grep "Wireless LAN" \
|
||||||
|
| sed 's/^\([[:digit:]]\).*/\1/')" >> sunshine-setup.sh
|
||||||
|
|
||||||
|
**Sudo Configuration**
|
||||||
|
|
||||||
|
We will manually change the permissions of ``/dev/uinput`` using ``chown``.
|
||||||
|
You need to use ``sudo`` to make this change, so add/update the entry in ``/etc/sudoers.d/${USER}``
|
||||||
|
|
||||||
|
.. danger::
|
||||||
|
Do so at your own risk! It is more secure to give sudo and no password prompt to a single script,
|
||||||
|
than a generic executable like chown.
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
Be very careful of messing this config up. If you make a typo, *YOU LOSE THE ABILITY TO USE SUDO*.
|
||||||
|
Fortunately, your system is not borked, you will need to login as root to fix the config.
|
||||||
|
You may want to setup a backup user / SSH into the host as root to fix the config if this happens.
|
||||||
|
Otherwise you will need to plug your machine back into a monitor and login as root to fix this.
|
||||||
|
To enable root login over SSH edit your SSHD config, and add ``PermitRootLogin yes``, and restart the SSH server.
|
||||||
|
|
||||||
|
#. First make a backup of your ``/etc/sudoers.d/${USER}`` file.
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
sudo cp /etc/sudoers.d/${USER} /etc/sudoers.d/${USER}.backup
|
||||||
|
|
||||||
|
#. ``cd`` to the parent dir of the ``sunshine-setup.sh`` script.
|
||||||
|
#. Execute the following to update your sudoer config file.
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
echo "${USER} ALL=(ALL:ALL) ALL, NOPASSWD: $(pwd)/sunshine-setup.sh" \
|
||||||
|
| sudo tee /etc/sudoers.d/${USER}
|
||||||
|
|
||||||
|
These changes allow the script to use sudo without being prompted with a password.
|
||||||
|
|
||||||
|
e.g. ``sudo $(pwd)/sunshine-setup.sh``
|
||||||
|
|
||||||
|
|
||||||
|
Stream Launcher Script
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
This is the main entrypoint script that will run the ``sunshine-setup.sh`` script, start up X server, and Sunshine.
|
||||||
|
The client will call this script that runs on the host via ssh.
|
||||||
|
|
||||||
|
|
||||||
|
**Sunshine Startup Script**
|
||||||
|
|
||||||
|
This guide will refer to this script as ``~/scripts/sunshine.sh``.
|
||||||
|
The setup script will be referred as ``~/scripts/sunshine-setup.sh``
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export DISPLAY=:0
|
||||||
|
|
||||||
|
# Check existing X server
|
||||||
|
ps -e | grep X >/dev/null
|
||||||
|
[[ ${?} -ne 0 ]] && {
|
||||||
|
echo "Starting X server"
|
||||||
|
startx &>/dev/null &
|
||||||
|
[[ ${?} -eq 0 ]] && {
|
||||||
|
echo "X server started successfully"
|
||||||
|
} || echo "X server failed to start"
|
||||||
|
} || echo "X server already running"
|
||||||
|
|
||||||
|
# Check if sunshine is already running
|
||||||
|
ps -e | grep -e .*sunshine$ >/dev/null
|
||||||
|
[[ ${?} -ne 0 ]] && {
|
||||||
|
sudo ~/scripts/sunshine-setup.sh
|
||||||
|
echo "Starting Sunshine!"
|
||||||
|
sunshine > /dev/null &
|
||||||
|
[[ ${?} -eq 0 ]] && {
|
||||||
|
echo "Sunshine started successfully"
|
||||||
|
} || echo "Sunshine failed to start"
|
||||||
|
} || echo "Sunshine is already running"
|
||||||
|
|
||||||
|
# Add any other Programs that you want to startup automatically
|
||||||
|
# e.g.
|
||||||
|
# steam &> /dev/null &
|
||||||
|
# firefox &> /dev/null &
|
||||||
|
# kdeconnect-app &> /dev/null &
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
SSH Client Setup
|
||||||
|
----------------
|
||||||
|
|
||||||
|
We will be setting up:
|
||||||
|
|
||||||
|
#. `SSH Key Authentication Setup`_
|
||||||
|
#. `SSH Client Script (Optional)`_
|
||||||
|
|
||||||
|
SSH Key Authentication Setup
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
#. Setup your SSH keys with ``ssh-keygen`` and use ``ssh-copy-id`` to authorize remote login to your host.
|
||||||
|
Run ``ssh <user>@<ip_address>`` to login to your host.
|
||||||
|
SSH keys automate login so you don't need to input your password!
|
||||||
|
#. Optionally setup a ``~/.ssh/config`` file to simplify the ``ssh`` command
|
||||||
|
|
||||||
|
.. code-block:: text
|
||||||
|
|
||||||
|
Host <some_alias>
|
||||||
|
Hostname <ip_address>
|
||||||
|
User <username>
|
||||||
|
IdentityFile ~/.ssh/<your_private_key>
|
||||||
|
|
||||||
|
Now you can use ``ssh <some_alias>``.
|
||||||
|
``ssh <some_alias> <commands/script>`` will execute the command or script on the remote host.
|
||||||
|
|
||||||
|
Checkpoint
|
||||||
|
^^^^^^^^^^
|
||||||
|
|
||||||
|
As a sanity check, let's make sure your setup is working so far!
|
||||||
|
|
||||||
|
**Test Steps**
|
||||||
|
|
||||||
|
With your monitor still plugged into your Sunshine host PC:
|
||||||
|
|
||||||
|
#. ``ssh <alias>``
|
||||||
|
#. ``~/scripts/sunshine.sh``
|
||||||
|
#. ``nvidia-smi``
|
||||||
|
|
||||||
|
You should see the sunshine and Xorg processing running:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
nvidia-smi
|
||||||
|
|
||||||
|
*Output:*
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
+---------------------------------------------------------------------------------------+
|
||||||
|
| NVIDIA-SMI 535.104.05 Driver Version: 535.104.05 CUDA Version: 12.2 |
|
||||||
|
|-----------------------------------------+----------------------+----------------------+
|
||||||
|
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
|
||||||
|
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
|
||||||
|
| | | MIG M. |
|
||||||
|
|=========================================+======================+======================|
|
||||||
|
| 0 NVIDIA GeForce RTX 3070 Off | 00000000:01:00.0 On | N/A |
|
||||||
|
| 30% 46C P2 45W / 220W | 549MiB / 8192MiB | 2% Default |
|
||||||
|
| | | N/A |
|
||||||
|
+-----------------------------------------+----------------------+----------------------+
|
||||||
|
|
||||||
|
+---------------------------------------------------------------------------------------+
|
||||||
|
| Processes: |
|
||||||
|
| GPU GI CI PID Type Process name GPU Memory |
|
||||||
|
| ID ID Usage |
|
||||||
|
|=======================================================================================|
|
||||||
|
| 0 N/A N/A 1393 G /usr/lib/Xorg 86MiB |
|
||||||
|
| 0 N/A N/A 1440 C+G sunshine 293MiB |
|
||||||
|
+---------------------------------------------------------------------------------------+
|
||||||
|
|
||||||
|
#. Check ``/dev/uinput`` permissions
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
ls -l /dev/uinput
|
||||||
|
|
||||||
|
*Output:*
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
crw------- 1 <user> <primary_group> 10, 223 Aug 29 17:31 /dev/uinput
|
||||||
|
|
||||||
|
#. Connect to Sunshine host from a moonlight client
|
||||||
|
|
||||||
|
Now kill X and sunshine by running ``pkill X`` on the host,
|
||||||
|
unplug your monitors from your GPU, and repeat steps 1 - 5.
|
||||||
|
You should get the same result.
|
||||||
|
With this setup you don't need to modify the Xorg config regardless if monitors are plugged in or not.
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
pkill X
|
||||||
|
|
||||||
|
|
||||||
|
SSH Client Script (Optional)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
At this point you have a working setup! For convenience I created this bash script to automate the
|
||||||
|
startup of the X server and Sunshine on the host.
|
||||||
|
This can be run on Unix systems, or on Windows using the ``git-bash`` or any bash shell.
|
||||||
|
|
||||||
|
For Android/iOS you can install Linux emulators, e.g. ``Userland`` for Android and ``ISH`` for iOS.
|
||||||
|
The neat part is that you can execute one script to launch Sunshine from your phone or tablet!
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
ssh_args="<user>@192.168.X.X" # Or use alias set in ~/.ssh/config
|
||||||
|
|
||||||
|
check_ssh(){
|
||||||
|
result=1
|
||||||
|
# Note this checks infinitely, you could update this to have a max # of retries
|
||||||
|
while [[ $result -ne 0 ]]
|
||||||
|
do
|
||||||
|
echo "checking host..."
|
||||||
|
ssh $ssh_args "exit 0" 2>/dev/null
|
||||||
|
result=$?
|
||||||
|
[[ $result -ne 0 ]] && {
|
||||||
|
echo "Failed to ssh to $ssh_args, with exit code $result"
|
||||||
|
}
|
||||||
|
sleep 3
|
||||||
|
done
|
||||||
|
echo "Host is ready for streaming!"
|
||||||
|
}
|
||||||
|
|
||||||
|
start_stream(){
|
||||||
|
echo "Starting sunshine server on host..."
|
||||||
|
echo "Start moonlight on your client of choice"
|
||||||
|
# -f runs ssh in the background
|
||||||
|
ssh -f $ssh_args "~/scripts/sunshine.sh &"
|
||||||
|
}
|
||||||
|
|
||||||
|
check_ssh
|
||||||
|
start_stream
|
||||||
|
exit_code=${?}
|
||||||
|
|
||||||
|
sleep 3
|
||||||
|
exit ${exit_code}
|
||||||
|
|
||||||
|
Next Steps
|
||||||
|
----------
|
||||||
|
|
||||||
|
Congrats you can now stream your desktop headless! When trying this the first time,
|
||||||
|
keep your monitors close by incase something isn't working right.
|
||||||
|
|
||||||
|
If you have any feedback and any suggestions, feel free to make a post on Discord!
|
||||||
|
|
||||||
|
.. seealso::
|
||||||
|
Now that you have a virtual display, you may want to automate changing the resolution
|
||||||
|
and refresh rate prior to connecting to an app. See :ref:`Changing Resolution and
|
||||||
|
Refresh Rate <about/guides/app_examples:linux>` for more information.
|
||||||
9
docs/source/about/guides/linux/linux.rst
Normal file
9
docs/source/about/guides/linux/linux.rst
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
Linux
|
||||||
|
======
|
||||||
|
|
||||||
|
Collection of Sunshine Linux host guides.
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 1
|
||||||
|
|
||||||
|
headless_ssh
|
||||||
@@ -22,13 +22,29 @@ Usage
|
|||||||
.. Attention:: The configuration file specified will be created if it doesn't exist.
|
.. Attention:: The configuration file specified will be created if it doesn't exist.
|
||||||
|
|
||||||
**Start Sunshine over SSH (Linux/X11)**
|
**Start Sunshine over SSH (Linux/X11)**
|
||||||
|
Assuming you are already logged into the host, you can use this command
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
ssh -t <user>@<ip_address> 'startx &; export DISPLAY=:0; sunshine'
|
ssh <user>@<ip_address> 'export DISPLAY=:0; sunshine'
|
||||||
|
|
||||||
.. Note:: You could also utilize the ``~/.bash_profile`` or ``~/.bashrc`` files to setup the ``DISPLAY``
|
If you are logged into the host with only a tty (teletypewriter), you can use ``startx`` to start the
|
||||||
|
X server prior to executing sunshine.
|
||||||
|
You nay need to add ``sleep`` between ``startx`` and ``sunshine`` to allow more time for the display to be ready.
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
ssh <user>@<ip_address> 'startx &; export DISPLAY=:0; sunshine'
|
||||||
|
|
||||||
|
.. tip:: You could also utilize the ``~/.bash_profile`` or ``~/.bashrc`` files to setup the ``DISPLAY``
|
||||||
variable.
|
variable.
|
||||||
|
|
||||||
|
.. seealso::
|
||||||
|
|
||||||
|
See :ref:`Remote SSH Headless Setup
|
||||||
|
<about/guides/linux/headless_ssh:Remote SSH Headless Setup>` on
|
||||||
|
how to setup a headless streaming server without autologin and dummy plugs (X11 + NVidia GPUs)
|
||||||
|
|
||||||
#. Configure Sunshine in the web ui
|
#. Configure Sunshine in the web ui
|
||||||
|
|
||||||
The web ui is available on `https://localhost:47990 <https://localhost:47990>`__ by default. You may replace
|
The web ui is available on `https://localhost:47990 <https://localhost:47990>`__ by default. You may replace
|
||||||
@@ -251,7 +267,7 @@ Application List
|
|||||||
|
|
||||||
- ``working-dir`` - The working directory to use. If not specified, Sunshine will use the application directory.
|
- ``working-dir`` - The working directory to use. If not specified, Sunshine will use the application directory.
|
||||||
|
|
||||||
- For more examples see :ref:`app examples <about/app_examples:app examples>`.
|
- For more examples see :ref:`app examples <about/guides/app_examples:app examples>`.
|
||||||
|
|
||||||
Considerations
|
Considerations
|
||||||
--------------
|
--------------
|
||||||
@@ -281,10 +297,17 @@ You must have an HDR-capable display or EDID emulator dongle connected to your h
|
|||||||
- Older games that use NVIDIA-specific NVAPI HDR rather than native Windows 10 OS HDR support may not display in HDR.
|
- Older games that use NVIDIA-specific NVAPI HDR rather than native Windows 10 OS HDR support may not display in HDR.
|
||||||
- Some GPUs can produce lower image quality or encoding performance when streaming in HDR compared to SDR.
|
- Some GPUs can produce lower image quality or encoding performance when streaming in HDR compared to SDR.
|
||||||
|
|
||||||
Tutorials
|
.. seealso::
|
||||||
---------
|
`Arch wiki on HDR Support for Linux <https://wiki.archlinux.org/title/HDR_monitor_support>`__ and
|
||||||
Tutorial videos are available `here <https://www.youtube.com/playlist?list=PLMYr5_xSeuXAbhxYHz86hA1eCDugoxXY0>`__.
|
`Reddit Guide for HDR Support for AMD GPUs
|
||||||
|
<https://www.reddit.com/r/linux_gaming/comments/10m2gyx/guide_alpha_test_hdr_on_linux>`__
|
||||||
|
|
||||||
|
Tutorials and Guides
|
||||||
|
--------------------
|
||||||
|
Tutorial videos are available `here <https://www.youtube.com/playlist?list=PLMYr5_xSeuXAbhxYHz86hA1eCDugoxXY0>`_.
|
||||||
|
|
||||||
|
Guides are available :doc:`here <./guides/guides>`.
|
||||||
|
|
||||||
.. admonition:: Community!
|
.. admonition:: Community!
|
||||||
|
|
||||||
Tutorials are community generated. Want to contribute? Reach out to us on our discord server.
|
Tutorials and Guides are community generated. Want to contribute? Reach out to us on our discord server.
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ extensions = [
|
|||||||
'sphinx.ext.graphviz', # enable graphs for breathe
|
'sphinx.ext.graphviz', # enable graphs for breathe
|
||||||
'sphinx.ext.viewcode', # add links to view source code
|
'sphinx.ext.viewcode', # add links to view source code
|
||||||
'sphinx_copybutton', # add a copy button to code blocks
|
'sphinx_copybutton', # add a copy button to code blocks
|
||||||
|
'sphinx_inline_tabs', # add tabs
|
||||||
]
|
]
|
||||||
|
|
||||||
# Add any paths that contain templates here, relative to this directory.
|
# Add any paths that contain templates here, relative to this directory.
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ sphinx docs. Installation and setup of python will not be covered here.
|
|||||||
Doxygen is used to generate the XML files required by Sphinx. Doxygen can be obtained from
|
Doxygen is used to generate the XML files required by Sphinx. Doxygen can be obtained from
|
||||||
`Doxygen downloads <https://www.doxygen.nl/download.html>`__. Ensure that the `doxygen` executable is in your path.
|
`Doxygen downloads <https://www.doxygen.nl/download.html>`__. Ensure that the `doxygen` executable is in your path.
|
||||||
|
|
||||||
|
.. seealso::
|
||||||
|
Sphinx is configured to use the graphviz extension. To obtain the dot executable from the Graphviz library,
|
||||||
|
see the `library’s downloads section <https://graphviz.org/download/>`__.
|
||||||
|
|
||||||
|
|
||||||
The config file for Sphinx is `docs/source/conf.py`. This is already included in the repo and should not be modified.
|
The config file for Sphinx is `docs/source/conf.py`. This is already included in the repo and should not be modified.
|
||||||
|
|
||||||
The config file for Doxygen is `docs/Doxyfile`. This is already included in the repo and should not be modified.
|
The config file for Doxygen is `docs/Doxyfile`. This is already included in the repo and should not be modified.
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
about/docker
|
about/docker
|
||||||
about/third_party_packages
|
about/third_party_packages
|
||||||
about/usage
|
about/usage
|
||||||
about/app_examples
|
about/guides/guides
|
||||||
about/advanced_usage
|
about/advanced_usage
|
||||||
about/changelog
|
about/changelog
|
||||||
|
|
||||||
|
|||||||
@@ -32,4 +32,4 @@ If screencasting fails with KMS, you may need to run the following to force unpr
|
|||||||
|
|
||||||
Gamescope compatibility
|
Gamescope compatibility
|
||||||
-----------------------
|
-----------------------
|
||||||
Some users have reported stuttering issues when streaming games running within Gamescope.
|
Some users have reported stuttering issues when streaming games running within Gamescope.
|
||||||
|
|||||||
@@ -318,9 +318,9 @@
|
|||||||
<tr><td style="font-family: monospace">SUNSHINE_CLIENT_AUDIO_CONFIGURATION</td><td>The Audio Configuration requested by the client (2.0/5.1/7.1)</td></tr>
|
<tr><td style="font-family: monospace">SUNSHINE_CLIENT_AUDIO_CONFIGURATION</td><td>The Audio Configuration requested by the client (2.0/5.1/7.1)</td></tr>
|
||||||
</table>
|
</table>
|
||||||
<div class="form-text" v-if="platform === 'windows'"><b>Example - QRes for Resolution Automation:</b> <pre>cmd /C <qres path>\QRes.exe /X:%SUNSHINE_CLIENT_WIDTH% /Y:%SUNSHINE_CLIENT_HEIGHT%</pre></div>
|
<div class="form-text" v-if="platform === 'windows'"><b>Example - QRes for Resolution Automation:</b> <pre>cmd /C <qres path>\QRes.exe /X:%SUNSHINE_CLIENT_WIDTH% /Y:%SUNSHINE_CLIENT_HEIGHT%</pre></div>
|
||||||
<div class="form-text" v-else-if="platform === 'linux'"><b>Example - Xrandr for Resolution Automation:</b> <pre>sh -c "xrandr --output HDMI-1 --mode \"${SUNSHINE_CLIENT_WIDTH}x${SUNSHINE_CLIENT_HEIGHT}\" --range 60"</pre></div>
|
<div class="form-text" v-else-if="platform === 'linux'"><b>Example - Xrandr for Resolution Automation:</b> <pre>sh -c "xrandr --output HDMI-1 --mode \"${SUNSHINE_CLIENT_WIDTH}x${SUNSHINE_CLIENT_HEIGHT}\" --rate 60"</pre></div>
|
||||||
<div class="form-text" v-else-if="platform === 'macos'"><b>Example - displayplacer for Resolution Automation:</b> <pre>sh -c "displayplacer "id:<screenId> res:${SUNSHINE_CLIENT_WIDTH}x${SUNSHINE_CLIENT_HEIGHT} hz:60 scaling:on origin:(0,0) degree:0""</pre></div>
|
<div class="form-text" v-else-if="platform === 'macos'"><b>Example - displayplacer for Resolution Automation:</b> <pre>sh -c "displayplacer "id:<screenId> res:${SUNSHINE_CLIENT_WIDTH}x${SUNSHINE_CLIENT_HEIGHT} hz:60 scaling:on origin:(0,0) degree:0""</pre></div>
|
||||||
<div class="form-text"><a href="https://docs.lizardbyte.dev/projects/sunshine/en/latest/about/app_examples.html" target="_blank">See More</a></div>
|
<div class="form-text"><a href="https://docs.lizardbyte.dev/projects/sunshine/en/latest/about/guides/app_examples.html" target="_blank">See More</a></div>
|
||||||
</div>
|
</div>
|
||||||
<!--buttons-->
|
<!--buttons-->
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
|
|||||||
Reference in New Issue
Block a user