LXQt with VNC
This guide will help you set up the lightweight LXQt desktop environment with VNC on a Debian EC2 instance, allowing for a graphical desktop interface through a secure connection.
Initial Setup
# Update system packages
sudo apt update
sudo apt upgrade -y
# Install LXQt desktop environment
sudo apt install lxqt -y
# Install TigerVNC server
sudo apt install tigervnc-standalone-server tigervnc-common -y
# Set VNC password - you will be prompted to enter a password
vncpasswd
# Create VNC config directory if it doesn't exist
mkdir -p ~/.vnc
# Create a simple xstartup file
cat > ~/.vnc/xstartup << 'EOF'
#!/bin/sh
export XDG_SESSION_TYPE=x11
export DESKTOP_SESSION=lxqt
exec startlxqt
EOF
# Make xstartup executable
chmod +x ~/.vnc/xstartup
# Kill any existing VNC server instances (optional, use if needed)
# vncserver -kill :1
# Start VNC server
vncserver :1
Connecting to Your VNC Server
From your local machine:
# Create SSH tunnel and keep it open
# Replace with your actual key file and EC2 public DNS
ssh -L 5901:localhost:5901 -i "your-key.pem" user@your-ec2-public-dns "vncserver :1; sleep infinity"
In a new terminal window on your local machine:
# Connect to the VNC server using TigerVNC viewer
xtigervncviewer localhost:1
Useful VNC Management Commands
# Check if VNC server is running
vncserver -list
# Manually kill VNC server
vncserver -kill :1
# Start VNC with specific resolution
vncserver :1 -geometry 1920x1080
# Start VNC with more parameters (depth, geometry, etc.)
vncserver :1 -depth 24 -geometry 1920x1080 -localhost no
Security Best Practices
- Always use SSH tunneling when connecting over the internet
- Keep your EC2 security group restrictive (don't open VNC port 5901 publicly)
- Use a strong VNC password
- Consider using
-localhost yes
parameter when starting VNC to only allow connections via SSH tunnel