Debian 10配置tigervnc

tigervnc分为tigervnc-standalone-server和tigervnc-scraping-server,分别对应vncserver和x0vncserver,也就是一个是独立于本地X11的,一个是类似于RDP和本地共享X11的,这里我们配置standalone-server

$ apt install tigervnc-standalone-server

进入使用vnc的用户,使用vncpasswd设置密码

$ vncpasswd

配置~/.vnc/xstartup,该文件类似于xinitrc,这里我用的是mate桌面

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

#export XKL_XMODMAP_DISABLE=1
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
# x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
mate-session &

由于vnc不带加密,我们一般通过ssh隧道连接,开启vnc服务命令为

$ vncserver -geometry 1440x900 -alwaysshared -localhost

写一个systemd脚本方便管理

/etc/systemd/system/vncserver@.service
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=forking
User=yachen
WorkingDirectory=/home/yachen
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/bin/vncserver %i -geometry 1440x900 -alwaysshared -localhost
ExecStop=/usr/bin/vncserver -kill %i

[Install]
WantedBy=multi-user.target
$ systemctl daemon-reload
$ systemctl enable vncserver@:1 --now

此处评论已关闭