Last active
November 10, 2022 04:55
-
-
Save mokiding/78d02bbcbcacd4b2dae0 to your computer and use it in GitHub Desktop.
How to install VNC server ubuntu digitalocean
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
just edit the vnc_user in this text | |
------------------------------- | |
apt-get install gnome-core xfce4 firefox | |
apt-get install vnc4server | |
adduser vnc_user | |
su - vnc_user | |
vncserver | |
cp ~/.vnc/xstartup ~/.vnc/xstartup.bak | |
rm -rf ~/.vnc/xstartup | |
nano ~/.vnc/xstartup | |
------------------- | |
#!/bin/sh | |
unset SESSION_MANAGER | |
unset DBUS_SESSION_BUS_ADDRESS | |
startxfce4 & | |
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup | |
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources | |
xsetroot -solid grey | |
vncconfig -iconic & | |
---------------------- | |
vncserver -kill :1 | |
su | |
nano /etc/init.d/vncserver | |
------------------------ | |
#!/bin/bash | |
unset VNCSERVERARGS | |
VNCSERVERS="" | |
[ -f /etc/vncserver/vncservers.conf ] && . /etc/vncserver/vncservers.conf | |
prog=$"VNC server" | |
start() { | |
. /lib/lsb/init-functions | |
REQ_USER=$2 | |
echo -n $"Starting $prog: " | |
ulimit -S -c 0 >/dev/null 2>&1 | |
RETVAL=0 | |
for display in ${VNCSERVERS} | |
do | |
export USER="${display##*:}" | |
if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then | |
echo -n "${display} " | |
unset BASH_ENV ENV | |
DISP="${display%%:*}" | |
export VNCUSERARGS="${VNCSERVERARGS[${DISP}]}" | |
su ${USER} -c "cd ~${USER} && [ -f .vnc/passwd ] && vncserver :${DISP} ${VNCUSERARGS}" | |
fi | |
done | |
} | |
stop() { | |
. /lib/lsb/init-functions | |
REQ_USER=$2 | |
echo -n $"Shutting down VNCServer: " | |
for display in ${VNCSERVERS} | |
do | |
export USER="${display##*:}" | |
if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then | |
echo -n "${display} " | |
unset BASH_ENV ENV | |
export USER="${display##*:}" | |
su ${USER} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1 | |
fi | |
done | |
echo -e "\n" | |
echo "VNCServer Stopped" | |
} | |
case "$1" in | |
start) | |
start $@ | |
;; | |
stop) | |
stop $@ | |
;; | |
restart|reload) | |
stop $@ | |
sleep 3 | |
start $@ | |
;; | |
condrestart) | |
if [ -f /var/lock/subsys/vncserver ]; then | |
stop $@ | |
sleep 3 | |
start $@ | |
fi | |
;; | |
status) | |
status Xvnc | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|restart|condrestart|status}" | |
exit 1 | |
esac | |
------------------- | |
chmod +x /etc/init.d/vncserver | |
mkdir -p /etc/vncserver | |
nano /etc/vncserver/vncservers.conf | |
-------- ZIPA OVDE TREBA vpn_user---------- | |
VNCSERVERS="1:vpn_user" | |
VNCSERVERARGS[1]="-geometry 1024x768" | |
------------------ | |
update-rc.d vncserver defaults 99 | |
reboot | |
======================================================== | |
If you want to add more vnc servers to this box then just add it to /etc/vncserver/vncservers.conf file | |
VNCSERVERS="2:steven" | |
VNCSERVERARGS[2]="-geometry 1024x768" | |
VNCSERVERS="3:marc" | |
VNCSERVERARGS[3]="-geometry 1024x768" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment