如何优雅的桌面远程Ubuntu

如何优雅的桌面远程Ubuntu

作为Ubuntu系统来讲,一般ssh + sftp对于大部分需求都可以满足,但例如想查看一批图片,亦或是想在Ubuntu系统上用IDE调试代码,那我们就会需要用到远程桌面这个功能。

有两种解决方案:

  1. Xfce + TightVNC
  2. Ubuntu自带屏幕分享

先来说说第一种方案的缺点,开启UbuntuXfce + TightVNC之后,自身的桌面服务无法启动,(一般来说,windows的远程桌面,被远程的机器也是无法操控桌面的。)所以这种方案适用于远程机器不使用桌面服务的场景。具体操作如下:

安装Xfce及TightVNC

sudo apt update
sudo apt install xfce4 xfce4-goodies
sudo apt install tightvncserver

启动vncserver并进行配置:

vncserver
Password:
Verify:

Would you like to enter a view-only password (y/n)? n
xauth:  file /home/yourname/.Xauthority does not exist

New 'X' desktop is your_hostname:1

将刚才启动的vncserver终止,修改配置文件

vncserver -kill :1
mv ~/.vnc/xstartup ~/.vnc/xstartup.bak
vim ~/.vnc/xstartup

修改xstartup

#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &

推出并保存,设置xstartup权限

sudo chmod +x ~/.vnc/xstartup

再次启动vncserver,可以配置对应屏幕分辨率:

vncserver -geometry 1920x1080

启动成功将输出:

New 'X' desktop is your_hostname:1

Starting applications specified in /home/yourname/.vnc/xstartup
Log file is /home/yourname/.vnc/your_hostname:1.log

此时,重启Ubuntu系统,在另一台机器上下载VNC客户端进行连接:

ip输入:1.2.3.4:1

其他配置默认。


对于第二种方案,自由度更大,笔者也更推荐。配置如下:

sudo apt-get install dconf-editor

开启Ubunut系统自带屏幕分享权限:

图片来自网络,侵权删除

在应用程序列表找到dconf:

图片来自网络,侵权删除

通过dconf去掉系统默认的“requlre-encryption”(路径:org > gnome > desktop > remote-access)

图片来自网络,侵权删除

到此配置完成。下面进行连接,注意端口号5900:

图片来自网络,侵权删除

参考:

编辑于 2020-04-06 16:54