执行apt-get update更新下
apt-get update
安装桌面环境
sudo apt install xfce4 xfce4-goodies
安装vncserver
apt install tightvncserver
启动vncserver服务并初始化
root@wxj-virtual-machine:~# vncserver
You will require a password to access your desktops.
Password:
Verify:
Would you like to enter a view-only password (y/n)?
xauth: file /root/.Xauthority does not exist
New 'X' desktop is wxj-virtual-machine:1
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/wxj-virtual-machine:1.log
这时候远程登录看到桌面环境是一片空白
配置下vncserver的参数
vncserver -kill :1
mv ~/.vnc/xstartup ~/.vnc/xstartup.bak
vim ~/.vnc/xstartup
增加以下内容
#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &
增加执行权限
chmod +x ~/.vnc/xstartup
重新启动vncserver服务之后重新链接查看,成功看到桌面环境
vncserver -kill :1
vncserver
连接信息
看到如下界面成功配置
sudo apt-get install x11vnc
x11vnc -store passwd
执行该命令之后,会要求输入两次vnc密码,最后确认是否将密码配置写入当前用户家目录的/.vnc/passwd文件中,我们输入y进行确认,复制该配置文件到/etc/x11vnc.pass,并赋予可读权限
sudo vim /lib/systemd/system/x11vnc.service
[Unit]
Description=Start x11vnc at startup.
After=multi-user.target
[Service]
Type=simple
ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /etc/x11vnc.pass -rfbport 5900 -shared
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable x11vnc.service
sudo systemctl start x11vnc.service
使用VNC客户端(如VNC Viewer),填入IP地址连接,再输入之前设的密码,就可以远程访问桌面了。
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)