Steam-Headless / docker-steam-headless

A Headless Steam Docker image supporting NVIDIA GPU and accessible via Web UI
GNU General Public License v2.0
909 stars 89 forks source link

VNC Password Authentication #29

Open lijamez opened 1 year ago

lijamez commented 1 year ago

Is your feature request related to a problem?

Sometimes, we need to log into the server to do admin things, such as logging back into Steam in case it decides to log out of the account, restart Steam in case it crashes, etc. noVNC is a reliable and accessible way to manage the server. However, currently anyone on the local network can access the host through noVNC.

What is your feature request?

When VNC is enabled, we should have the option to set a password.

Are there any workarounds?

No response

Additional Context

No response

Bortus-AI commented 10 months ago

a password would be nice since my server is hosted in a data center. Anyone with the IP and port can access the web ui

doodooboi commented 8 months ago

I figured out a workaround to setup a password for the VNC server Connect through the WebUI and go to Applications > Terminal Emulator

Enter this command into the terminal: sudo nano /usr/bin/start-x11vnc.sh Edit a portion of the file to include the -passwd flag, example below

Start the x11vnc server

/usr/bin/x11vnc -display ${DISPLAY} -rfbport ${PORT_VNC} -passwd YOUR_PASSWORD -shared -forever& x11vnc_pid=$!

Now go back to your real machine where the docker container is running, cd into the directory and run sudo docker compose restart

janlothar commented 5 months ago

I got a little tired of having to always add that myself whenever the image got updated and the start-x11vnc.sh got scrubbed, so I made a little script designed to be placed in the /home/default/init.d directory. It won't handle weird edge cases, but it's enough until the maintainer (hopefully) adds this as a official feature.

Just make sure that the USER_PASSWORD variable exists or replace that part of the script with your own.

#!/bin/bash

# Define the file path
FILE_PATH="/usr/bin/start-x11vnc.sh"

# Define the password part to insert
PASSWORD_PART="-passwd $USER_PASSWORD"

# Check if the -passwd option is already in the script
if grep -q "\-passwd" "$FILE_PATH"; then
    echo "VNC Password flag already exists."
else
    echo "Adding VNC password flag..."
    # Use sed to insert the password part before the '&' at the end of the command line
    sed -i "/x11vnc.*\&/s/\&/ $PASSWORD_PART&/" "$FILE_PATH"
    echo "VNC Password flag added successfully."
fi