Skip to content

Instantly share code, notes, and snippets.

@smutao
Last active August 9, 2023 07:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smutao/8ada9616747dda539670f4bcdfc32154 to your computer and use it in GitHub Desktop.
Save smutao/8ada9616747dda539670f4bcdfc32154 to your computer and use it in GitHub Desktop.
debian/ubuntu+xfce+noVNC
#https://www.server-world.info/en/note?os=Debian_11&p=desktop&f=8
#https://www.server-world.info/en/note?os=Debian_11&p=desktop&f=6
# this script should work on Debian/Ubuntu
# it assumes that you are using 'root' user
# smutao@github, 2023
read -p "Enter VNC password: " mypass
read -p "Enter VNC resolution (e.g. 1920x1080 or 1600x900): " res
export DEBIAN_FRONTEND=noninteractive
apt update
apt --yes --force-yes install novnc python3-websockify curl wget
apt --yes --force-yes install tigervnc-standalone-server expect
apt --yes --force-yes install xfce4 xfce4-terminal
apt --yes --force-yes install dbus-x11
#script:
prog=/usr/bin/vncpasswd
#mypass="mima"
/usr/bin/expect <<EOF
spawn "$prog"
expect "Password:"
send "$mypass\r"
expect "Verify:"
send "$mypass\r"
expect "Would you like to enter a view-only password (y/n)?"
send "n\r"
expect eof
exit
EOF
tigervncserver -xstartup /usr/bin/xfce4-session -geometry $res -localhost no :1
# we can access VNC via 5901 port
cd /root/
openssl req -x509 -nodes -newkey rsa:3072 -keyout novnc.pem -out novnc.pem -days 3650 -subj "/C=JP/ST=Hiroshima/L=Hiroshima/O=GTS/OU=Server World/CN=cnn.com/emailAddress=debian@srv.world"
websockify -D --web=/usr/share/novnc/ --cert=/root/novnc.pem 6080 localhost:5901
ipip=`curl -4 ip.sb`
echo "for server on internet please visit https://$ipip:6080/vnc.html"
echo "for local server, please visit https://localhost:6080/vnc.html"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment