标签 VNCServer 下的文章

安装tightvncserver
sudo apt install tightvncserver
启动
vncserver :1
设置远程访问密码
修改密码
vncpasswd

用vnc登录 ip:1

关闭VNC服务
vncserver -kill :1

先备份xstartup原始文件,再编辑
sudo mv -v .vnc/xstartup .vnc/xstartup.backup
sudo nano ~/.vnc/xstartup

#!/bin/sh
export XKL_XMODMAP_DISABLE=1
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
 
exec /etc/X11/xinit/xinitrc
 
xfce4-panel &
xfsettingsd &
xfwm4 &
xfdesktop &
pcmanfm &
xfce4-terminal &
 
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
 
startxfce4 &

更改配置文件的权限:
sudo chmod +x ~/.vnc/xstartup

我这边装的桌面是 xfce4

开机自动启动
sudo nano /etc/systemd/system/vncserver@.service

[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target

[Service]
Type=simple
User=chip
PAMName=login
PIDFile=/home/%u/.vnc/%H%i.pid
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1024x768 %i

[Install]
WantedBy=multi-user.target 

sudo systemctl daemon-reload
sudo systemctl enable vncserver@:1.service

关闭
vncserver -kill :1

启动
sudo systemctl start vncserver@:1.service

最后重启
sudo reboot