I’ve had way too many problems trying to run tightvncserver on Rpi3 under Kali that I decided to rip out the tighvncserver and try vnc4derver daemon. The main problem was that it would give me a blank screen with a X cursor randomly. It would work fine one day and wouldn’t work the next time, and nobody had fiddled with any configurations to make it go wonky.
- SSH onto the Rpi3/Kali
- apt-get update
- apt-get install vnc4server
- After that run commands as shown below
root@Kali:~# vncpasswd
Password:
Verify:
root@Kali:~# vncserver :1
New 'Kali:1 (root)' desktop is Kali:1
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/Kali:1.log
root@Kali:~# vncserver -kill :1
Killing Xvnc4 process ID 771
root@Kali:~# mv ~/.vnc/xstartup ~/.vnc/xstartup.bak
root@Kali:~# nano ~/.vnc/xstartup
root@Kali:~# sudo chmod +x ~/.vnc/xstartup
#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &
root@Kali:~# sudo nano /etc/init.d/vncserver
#!/bin/bash
PATH="$PATH:/usr/bin/"
export USER="root"
DISPLAY="1"
DEPTH="16"
GEOMETRY="1024x768"
OPTIONS="-depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY} -localhost"
. /lib/lsb/init-functions
case "$1" in
start)
log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
;;
stop)
log_action_begin_msg "Stopping vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
;;
restart)
$0 stop
$0 start
;;
esac
exit 0
root@Kali:~# sudo chmod +x /etc/init.d/vncserver
root@Kali:~# nano /etc/systemd/system/[email protected]
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
User=root
PAMName=login
PIDFile=/home/pi/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i
[Install]
WantedBy=multi-user.target
root@Kali:~# chmod +x /etc/systemd/system/[email protected]
root@Kali:~# systemctl start [email protected]
root@Kali:~# systemctl daemon-reload && sudo systemctl enable [email protected]
Conclusion
Now go ahead and install a VNC viewer on your main machine and connect to appropriate IP given to the Rpi3, for e.g. 192.168.1.10:1
Tags: Electronics Linux Remote Access VNC