sudo apt-get install xrdp
sudo apt-get install xrdp vnc4server
sudo apt-get update sudo apt-get install xfce4 xfce4-goodies
首先进入root帐户,启动vncserver。第一次启动通常都须要输入密码,对于root用户,密码文件将保存在/root/.vnc/passwd下,对于sudo权限的用户,密码文件保存在家目录/.vnc/passwd。若是忘记密码, 能够删除这个文件,再次运行vncserver设置密码。html
设置好密码后,vncserver启动,在端口5901启动一个默认的服务器实例。5901端口被称为显示器端口,并经过VNC所提到的:1。 VNC能够在其余显示器端口启动多个实例,如:2,:3,等等。linux
当使用VNC服务器时,请记住:X是指显示器端口5900+X。web
在.vnc文件夹中,还有一个很是重要的脚本: xstartup。这个脚本能够设置vnc远程桌面的基本选项。ubuntu
打开该脚本,将原文件注释掉,添加下面两行:bash
#!/bin/bash xrdb $HOME/.Xresources startxfce4 &
xrdb $HOME/.Xresources
,讲述了VNC的GUI框架读取服务器用户.Xresources文件。.Xresources是用户能够更改图形化桌面的某些设置,如终端的颜色,光标主题,和字体呈现。修改xstartup脚本后,保存退出。关闭当前vncserver实例:
vncserver -kill :1
以后再从新启动,更新vncserver设置:
vncserver :1
服务器
接下来,咱们将VNC服务器设置为systemd服务。 这将使其能够像任何其余systemd服务同样根据须要启动,中止和从新启动。
首先,建立/etc/systemd/system/vncserver@.service
:session
sudo gedit /etc/systemd/system/vncserver@.service
将如下内容复制并粘贴到其中。 必定要改变PIDFile的值用户的价值和用户名,以配合您的用户名。框架
/etc/systemd/system/vncserver@.service [Unit] Description=Start TightVNC server at startup After=syslog.target network.target [Service] Type=forking User=dell PAMName=login PIDFile=/home/dell/.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
保存并关闭文件。
接下来,让系统知道新的单元文件。svg
sudo systemctl daemon-reload
启用service:sudo systemctl enable vncserver@1.service
查看vncserver状态:sudo systemctl status vncserver@1
工具
若是它正确启动,输出应以下所示:
vncserver@1.service - TightVNC server on Ubuntu 16.04 Loaded: loaded (/etc/systemd/system/vncserver@.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2016-04-25 03:21:34 EDT; 6s ago Process: 2924 ExecStop=/usr/bin/vncserver -kill :%i (code=exited, status=0/SUCCESS) ... systemd[1]: Starting TightVNC server on Ubuntu 16.04... systemd[2938]: pam_unix(login:session): session opened for user finid by (uid=0) systemd[2949]: pam_unix(login:session): session opened for user finid by (uid=0) systemd[1]: Started TightVNC server on Ubuntu 16.04.
对于非root用户登陆服务器的状况,应该首先将xfce4-session写入该用户文件夹的xsession文件:/home/username/.xsession
echo "xfce4-session" >~/.xsession
以后继续配置xfce4
sudo vi /etc/xrdp/startwm.sh
在. /etc/X11/Xsession
前一行插入xfce4-session
设置非root用户的xstartup文件以下:
#!/bin/sh # Uncomment the following two lines for normal desktop: 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 x-terminal-emulator -geometry 1920*1600 -ls -title "$VNCDESKTOP Desktop" & # xfce4-session & xfdesktop & xfsettingsd & xfce4-menu-plugin & xfwm4 &
sudo service xrdp restart
非root用户:
http://www.noobyard.com/article/p-nvsnviuc-hg.html
https://blog.csdn.net/zz_1215/article/details/77921405
unbutu16.04配置xfce桌面:https://www.linuxprobe.com/ubuntu-vnc-xfce4.html