VNC远程桌面

1 介绍

给Ubuntu Sever 16.04版本:

  1. 安装桌面环境
  2. 远程使用桌面环境

简而言之就两个方面

2 安装桌面环境

linux的桌面环境有很多:

  • Gnome
  • Kde
  • Unity
  • 等等

Ubuntu 16.04默认的桌面环境是Unity,所以就安装Unity:

$ sudo apt-get update
$ sudo apt-get install ubuntu-desktop gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal

上述命令安装了其他类似LibreOffice等软件

然后reboot,进入云平台自带的远程连接就能够显示桌面了(注意此时仍然是guest会话,还不能以root用户登录):
image

3 远程使用桌面环境

3.1 VNC介绍

这里使用VNC。

VNC(Virtual Network Computing)是使用RFB(Remote Frame Buffer protocol)协议的图形桌面共享系统,可以达到远程控制桌面的效果。VNC是server-client架构:

server,称VNC server,常见的有:

  • x11vnc
  • vnc4server
  • tightvncserver

client,称VNC viewer,常见的有:

  • Remmina(Linux)
  • RealVNC(Windows MacOS)

这里我们选择x11vncRemmina,选择x11vnc的原因是:

  • x11vnc allows one to view remotely and interact with real X displays, unlike other Linux alternatives such as VNC4Server, 11vnc does not create an extra display (or X desktop) for remote control(不像VNC4Server会新建一个桌面,x11vnc是显示上面tty显示的桌面)
  • It has built-in SSL/TLS encryption and 2048 bit RSA authentication(wireshark抓包没有看到明文传输密码等信息)

使用x11vncvnc4server的对比图如下:

  • 使用x11vnc(移动鼠标可以看出是同步的):
    image

  • 使用vnc4server(显示了不同的桌面,vnc4server登录不需要实际的root密码):
    image

3.2 安装运行x11vnc

3.2.1 安装

$ sudo apt-get install x11vnc

3.2.2 设置密码

$ x11vnc -storepasswd
Enter VNC password: *********
Verify password: *********  
Write password to /root/.vnc/passwd?  [y]/n y
Password written to: /root/.vnc/passwd

3.2.3 运行

$ sudo x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /root/.vnc/passwd -rfbport 5900 -shared

xxx输出
The VNC desktop is:      iZwz9d9lrgata42idu99hsZ:0
PORT=5900
xxx

3.2.4 连接

使用viewerRemmina连接:
image

  • Server: IP:0(端口5900就填0,5901就填1)
  • Password:刚刚设置的密码

3.2.5 开机自起

vi /etc/rc.local填入如下内容(exit 0 之前):

/usr/bin/x11vnc -xkb -auth /var/run/lightdm/root/:0 -noxrecord -noxfixes -noxdamage -rfbauth /root/.vnc/passwd -forever -bg -rfbport 5900 -o /var/log/x11vnc.log  > /dev/null 2>&1

3.2.6 启用Login Screen

连接后发现登录界面只能使用访客会话,不能以root身份登录。vi /etc/lightdm/lightdm.conf(不存在就创建)填入如下内容来Enable Login Screen

[SeatDefaults]
greeter-session=unity-greeter
user-session=ubuntu
greeter-show-manual-login=true

reboot,然后就能以root身份登录了:
image

4 参考链接

http://www.karlrunge.com/x11vnc/
https://en.wikipedia.org/wiki/X11vnc
https://en.wikipedia.org/wiki/Virtual_Network_Computing
https://tecadmin.net/setup-x11vnc-server-on-ubuntu-linuxmint/
https://www.linode.com/docs/applications/remote-desktop/install-vnc-on-ubuntu-16-04/
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-16-04
http://www.configserverfirewall.com/ubuntu-linux/enable-ubuntu-desktop-root-login/

猜你喜欢

转载自blog.csdn.net/zqq840486874/article/details/82817444