debian 远程桌面_如何在Debian 10上使用X2Go设置远程桌面

本教程介绍了如何使用X2Go在Debian 10上创建远程桌面环境,以替代慢速且不安全的VNC。X2Go提供了快速的网络连接和响应式的桌面体验,适合需要在不同设备间保持一致工作环境或处理带宽有限的情况。教程涵盖了安装XFCE桌面环境、在服务器上安装X2Go、在本地安装X2Go客户端以及连接到远程桌面的步骤。
摘要由CSDN通过智能技术生成

debian 远程桌面

The author selected Software in the Public Interest (SPI) to receive a donation as part of the Write for DOnations program.

作者选择了公益软件(SPI)来接受捐赠,这是Write for DOnations计划的一部分。

介绍 (Introduction)

Usually, Linux-based servers don’t come with a graphical user interface (GUI) preinstalled. Whenever you want to run GUI applications on your instance, the typical solution is to employ Virtual Network Computing (VNC). Unfortunately, VNC is notoriously sluggish, insecure by default, and requires a lot of manual configuration to get up and running.

通常,基于Linux的服务器没有预先安装图形用户界面(GUI)。 每当您想在实例上运行GUI应用程序时,典型的解决方案就是采用虚拟网络计算(VNC)。 不幸的是,VNC非常缓慢,默认情况下不安全,并且需要大量的手动配置才能启动和运行。

By contrast, X2Go provides a working “cloud desktop,” complete with all the advantages of an always-online, remotely-accessible, and easily-scalable computing system with a very fast network. It is also more responsive and more secure than many VNC solutions. In this tutorial, you’ll use X2Go to create a Debian 10 XFCE desktop environment that you can access remotely. This “cloud desktop” will include the exact same utilities that you would obtain had you installed Debian 10 and the XFCE environment on your personal computer.

相比之下, X2Go提供了一个可运行的“云桌面”,并具有始终在线,可远程访问且易于扩展且具有快速网络的计算系统的所有优点。 与许多VNC解决方案相比,它还具有更高的响应速度和安全性。 在本教程中,您将使用X2Go创建可远程访问的Debian 10 XFCE桌面环境。 该“云桌面”将包含与在个人计算机上安装Debian 10和XFCE环境时将获得的完全相同的实用程序。

The setup described in this tutorial is useful when:

本教程中描述的设置在以下情况下很有用:

  • You need access to a Linux-based operating system, complete with a desktop environment, but can’t install it on your personal computer.

    您需要访问基于Linux的操作系统,该操作系统具有桌面环境,但是不能将其安装在您的个人计算机上。
  • You use multiple devices in multiple locations and would like to have a consistent work environment with the same tools, same look, same files, and same performance.

    您在多个位置使用多个设备,并希望拥有一个具有相同工具,相同外观,相同文件和相同性能的一致工作环境。
  • Your Internet service provider gives you very little bandwidth, but you need access to tens or hundreds of gigabytes of data.

    您的Internet服务提供商为您提供的带宽很少,但是您需要访问数十或数百GB的数据。
  • Long-running jobs make your local computer unavailable for hours or days. Imagine that you have to compile a very large project, and it will take 8 hours on your laptop. You won’t be able to watch movies or do anything else very resource-intensive while your project compiles. But if you run such jobs on your server, now your computer is free to perform other tasks.

    长时间运行的作业使您的本地计算机无法使用数小时或数天。 想象一下,您必须编译一个非常大的项目,并且在笔记本电脑上将花费8个小时。 在项目编译时,您将无法观看电影或执行其他任何占用大量资源的操作。 但是,如果您在服务器上运行此类作业,则您的计算机现在可以自由执行其他任务。
  • You’re working with a team, and it benefits them to have a common computer that they can access in order to collaborate on a project.

    您正在与团队合作,他们拥有一台可供他们访问以便在项目上进行协作的通用计算机将对他们有利。

先决条件 (Prerequisites)

Before starting this tutorial, you’ll need:

在开始本教程之前,您需要:

  • A Debian 10 x64 instance with 2GB of RAM or more. 2GB is minimal and it’s recommended to use a server with 4GB or more if you have memory-hungry applications you plan to run. You can use a DigitalOcean Droplet if you like.

    具有2GB或更多RAM的Debian 10 x64实例。 2GB是最小的,如果您打算运行需要大量内存的应用程序,建议使用4GB或更大的服务器。 如果愿意,可以使用DigitalOcean Droplet

  • A user with sudo privileges and an SSH key. Follow this guide to get started: Initial Server Setup with Debian 10. Make sure you complete Step 4 and configure your firewall to restrict all connections except for OpenSSH.

    具有sudo特权和SSH密钥的用户。 请遵循本指南进行入门: 使用Debian 10进行初始服务器设置 。 确保完成步骤4并将防火墙配置为限制除OpenSSH以外的所有连接。

第1步-安装桌面环境 (Step 1 — Installing the Desktop Environment)

With your server up and your firewall configured, you are now ready to install the graphical environment for the X2Go server.

在服务器启动并配置了防火墙之后,现在可以为X2Go服务器安装图形环境了。

In this tutorial, you are installing XFCE as the desktop environment. XFCE doesn’t use fancy graphical effects like compositing, which makes it more compatible with X2Go and allows it to optimize screen updates. For reference, LXDE and MATE (with compositing disabled) also work fine but you’ll have to change the command in this tutorial where you install the desktop environment. For example, instead of sudo apt-get install xfce4 you would type sudo apt-get install lxde.

在本教程中,您将XFCE安装为桌面环境。 XFCE不使用合成等奇特的图形效果,这使其与X2Go更加兼容,并可以优化屏幕更新。 作为参考, LXDEMATE (禁用了合成)也可以正常工作,但是您必须在安装桌面环境的本教程中更改命令。 例如,您可以输入sudo apt-get install lxde而不是sudo apt-get install xfce4

There are two ways to easily install XFCE, but you only need to choose one—either the Minimal Desktop Environment or the Full Desktop Environment.

有两种方法可以轻松地安装XFCE,但是您只需选择一种-最小桌面环境完整桌面环境。

Full Desktop Environment: Recommended. If you don’t want to handpick every component you need and would rather have a default set of packages, like a word processor, web browser, email client, and other accessories pre-installed, then you can choose task-xfce-desktop.

完整桌面环境:推荐。 如果您不想手动选择所需的每个组件,而是希望预先安装一套默认的软件包,例如字处理器,Web浏览器,电子邮件客户端和其他附件,则可以选择task-xfce-desktop

Install and configure the Full Desktop Environment. This is similar to what you would get if you installed Debian from a bootable DVD/USB memory stick to your local PC:

安装和配置完整桌面环境。 这类似于从可启动DVD / USB记忆棒将Debian安装到本地PC时所获得的内容:

  • sudo apt-get install task-xfce-desktop

    sudo apt-get install task-xfce-desktop

Minimal Desktop Environment: Alternately, if you want to install a small, core set of packages and then build on top of them by manually adding whatever you need afterward, you can use the xfce4 metapackage.

最小的桌面环境 :或者,如果您要安装一套小的核心软件包,然后通过手动添加所需的内容在它们之上构建,则可以使用xfce4 metapackage

A metapackage doesn’t contain software of its own, it just depends on other packages to be installed, allowing for an entire collection of packages to be installed at once without having to type each package name individually at the command line.

元软件包不包含自己的软件,它仅取决于要安装的其他软件包,从而允许一次安装整个软件包集合,而不必在命令行中分别键入每个软件包名称。

Install xfce4 and all of the additional dependencies needed to support it:

安装xfce4以及支持它的所有其他依赖项:

  • sudo apt-get install xfce4

    须藤apt-get install xfce4

Now that your graphical environment is installed, you will establish a way to view it remotely.

现在,您的图形环境已安装,您将建立一种远程查看它的方法。

第2步-在服务器上安装X2Go (Step 2 — Installing X2Go on the Server)

X2Go comes with two main components: the server, which starts and manages the graphical session on the remote machine, and the client, which you install on your local computer to view and control the remote desktop or application.

X2Go包含两个主要组件:服务器(用于启动和管理远程计算机上的图形会话),以及客户端(您可以将其安装在本地计算机上以查看和控制远程桌面或应用程序)。

In previous versions of Debian, x2goserver wasn’t included in the default repositories, so you’d have to follow steps like these to get the software package. We’re leaving the link here, just for reference, in case the package gets dropped in future versions of Debian. Fortunately, Debian 10, codenamed Buster, includes the package you need in its default repositories, so the installation is a bit easier.

在Debian的x2goserver版本中, x2goserver未包含在默认存储库中,因此您必须遵循以下步骤来获取软件包。 我们将链接保留在这里,仅供参考,以防软件包在以后的Debian版本中丢失。 幸运的是,代号为Buster的Debian 10在其默认存储库中包含了您所需的软件包,因此安装起来更加容易。

To install X2Go on your server, type the following command:

要在服务器上安装X2Go,请键入以下命令:

  • sudo apt-get install x2goserver x2goserver-xsession

    sudo apt-get install x2goserver x2goserver-xsession

At this point, no further setup is required on your server. However, keep in mind that since SSH password authentication is disabled, for increased security, you’ll need to have your SSH private key available on any machine that you want to log in from. This will be the case if you followed the recommendation of setting up SSH keys in the Initial Server Setup with Debian 10 tutorial listed in the prerequisites. If you didn’t, you can still log in with a password, but make sure you choose a strong one.

此时,无需在服务器上进行进一步的设置。 但是,请记住,由于禁用了SSH密码身份验证,为了提高安全性,您需要在要登录的任何计算机上使用SSH私钥。 如果遵循在先决条件中列出的“ 使用Debian 10进行初始服务器设置”教程中设置SSH密钥的建议,就会出现这种情况。 如果没有,您仍然可以使用密码登录,但请确保选择一个安全的密码。

Remember that if you run out of RAM, some applications might be abruptly terminated by the Linux kernel, and then you could lose work in progress. If you are using a DigitalOcean Droplet and you notice that your programs require more RAM, you can temporarily power off your Droplet and upgrade (resize) to one with more memory.

请记住,如果RAM用完了,某些应用程序可能会被Linux内核突然终止,然后您可能会丢失正在进行的工作。 如果您使用的是DigitalOcean Droplet,并且您注意到程序需要更多的RAM,则可以暂时关闭Droplet的电源并升级(调整大小)到具有更多内存的内存。

You are now done setting up the server and you can type exit or close the terminal window. The rest of the steps will focus on configuring the client on your local machine.

现在,您已经完成了服务器的设置,可以键入exit或关闭终端窗口。 其余步骤将重点放在在本地计算机上配置客户端。

步骤3 —在本地安装X2Go客户端 (Step 3 — Installing the X2Go Client Locally)

X2Go is ready to use out of the box. If you’re using Windows or Mac on your local machine, you can download the X2Go client software here. If you’re using Debian or Ubuntu you can install the X2Go client with this command on your local machine:

X2Go可以立即使用。 如果您在本地计算机上使用Windows或Mac,则可以在此处下载X2Go客户端软件。 如果您使用的是Debian或Ubuntu,则可以使用以下命令在本地计算机上安装X2Go客户端:

  • sudo apt-get install x2goclient

    sudo apt-get install x2goclient

After downloading the software you are ready to install it. Open the installer and select your preferred language. Now agree to the license and let the wizard guide you through the remaining steps. Normally, there shouldn’t be any reason to change the pre-filled, default values in these steps.

下载软件后,您就可以安装它了。 打开安装程序,然后选择您的首选语言。 现在,同意许可,然后让向导引导您完成其余步骤。 通常,在这些步骤中应该没有任何理由更改预填充的默认值。

X2Go works well out of the box but it is also highly customizable. If you’d like additional information, visit X2Go’s official documentation.

X2Go开箱即用,但高度可定制。 如果您需要其他信息,请访问X2Go的官方文档

Now that the desktop client is installed, you can configure its settings and connect to the X2Go server to use your remote XFCE desktop.

现在已经安装了桌面客户端,您可以配置其设置并连接到X2Go服务器以使用远程XFCE桌面。

步骤4 —连接到远程桌面 (Step 4 — Connecting To the Remote Desktop)

When you first open the X2Go client, the following window will appear. If it doesn’t, click Session in the top-left menu and then select New session ….

首次打开X2Go客户端时,将出现以下窗口。 如果不是这样,单击会话在左上角的菜单,然后选择新建会话...。

In the Session name field, enter something to help differentiate between servers. This can be particularly useful if you plan on connecting to multiple machines.

在“ 会话名称”字段中,输入一些内容以帮助区分服务器。 如果您打算连接到多台计算机,这将特别有用。

Enter your server’s IP address or hostname in the Host field under Server.

Host字段下服务器输入服务器的IP地址或主机名。

Enter the username you used for your SSH connection in the Login field.

登录字段中输入用于SSH连接的用户名。

And, since you installed XFCE in Step Two, choose XFCE as your Session type.

并且,由于您在第二步中安装了XFCE,因此请选择XFCE作为您的会话类型

Finally, because you are connecting to the server with SSH keys, click the folder icon next to Use RSA/DSA key for ssh connection and browse to your private key. If you didn’t opt to use the more secure SSH keys, just leave this empty and the X2Go client will ask for a password each time you log in.

最后,由于要使用SSH密钥连接到服务器,因此请单击“ 使用RSA / DSA密钥进行ssh连接”旁边的文件夹图标,然后浏览至私钥。 如果您不选择使用更安全的SSH密钥,则将其保留为空,每次登录时X2Go客户端都会要求输入密码。

The rest of the default settings will suffice for now, but as you get more familiar with the software, you can fine tune the client based on your individual preferences.

其余的默认设置现在就足够了,但是随着您对软件的熟悉程度的提高,您可以根据个人喜好微调客户端。

After pressing the OK button, you can start your graphical session by clicking the white box that includes your session’s name on the top-right side of the box.

按下“ 确定”按钮后,您可以通过单击框右上角包含会话名称的白色框来启动图形会话。

If you are running OS X on your local machine, you may be prompted to install xquartz, which is required to run X11. If so, follow the instructions to install it now.

如果您在本地计算机上运行OS X,则系统可能会提示您安装xquartz,这是运行X11所必需的。 如果是这样,请按照说明立即安装。

In a few seconds, your remote desktop will be displayed and you can start interacting with it. During your first login, XFCE will ask if you want to Use default config or One empty panel. The first option will create a rectangular panel docked at the bottom of the screen, containing a few useful application shortcuts (e.g. a file manager, a terminal emulator, a browser, etc.). This option will also add a top panel to the desktop that includes utilities like an application launcher, a clock, a shutdown menu, and more.

几秒钟后,将显示您的远程桌面,您可以开始与它进行交互。 首次登录期间,XFCE会询问您是否要使用默认配置一个空白面板 。 第一个选项将创建一个停靠在屏幕底部的矩形面板,其中包含一些有用的应用程序快捷方式(例如,文件管理器,终端仿真器,浏览器等)。 此选项还将在桌面上添加一个顶部面板,其中包括诸如应用程序启动器,时钟,关机菜单等实用程序。

Unless you’re already familiar with XFCE, opting for an empty panel can be more complicated because you’ll be starting from scratch. There will be no taskbar, no clock, and no pre-configured start menu; it will be up to you to add everything to an empty panel on your own.

除非您已经熟悉XFCE,否则选择空白面板可能会更加复杂,因为您将从头开始。 没有任务栏,没有时钟,也没有预配置的开始菜单; 您可以自行将所有内容添加到空白面板中。

Additionally, on Windows and Linux-based operating systems, there are a few useful keyboard shortcuts you can use for a better experience:

此外,在基于Windows和Linux的操作系统上,可以使用一些有用的键盘快捷键来获得更好的体验:

CTRL+ALT+F will toggle full-screen mode on and off. Working in full-screen mode can feel more like a local desktop experience. Plus, other keyboard shortcuts will be grabbed by the remote OS instead of the local one.

CTRL+ALT+F将打开和关闭全屏模式。 在全屏模式下工作更像是本地桌面体验。 另外,其他键盘快捷方式将由远程操作系统而不是本地操作系统获取。

CTRL+ALT+M will minimize the remote view, even if you are in full-screen mode

CTRL+ALT+M即使在全屏模式下也将最小化远程视图

CTRL+ALT+T will disconnect from the session but leave the GUI running on the server. It’s just a quick way of disconnecting without logging off or closing applications on the server. The same will happen if you click the window’s close button.

CTRL+ALT+T将断开会话连接,但GUI在服务器上运行。 这只是断开连接而无需注销或关闭服务器上的应用程序的快速方法。 如果您单击窗口的关闭按钮,也会发生同样的情况。

Lastly, there are two ways you can end the remote session and close all of the graphical programs running in it. You can log off remotely from XFCE’s start menu, or you can click the button marked with a circle and a small line (like a power/standby icon) in the bottom-right corner of the main portion of the X2Go screen.

最后,您可以通过两种方式结束远程会话并关闭其中运行的所有图形程序。 您可以从XFCE的“ 开始”菜单中远程注销,也可以单击X2Go屏幕主要部分右下角带有圆圈和小线(如电源/待机图标)的按钮。

The first method is cleaner but may leave programs like session managing software running. The second method will close everything but may do so forcefully if a process can’t cleanly exit. In either case, be sure to save your work before proceeding.

第一种方法比较干净,但可能会使诸如会话管理软件之类的程序运行。 第二种方法将关闭所有内容,但是如果进程无法彻底退出,则可以强制执行此操作。 无论哪种情况,请务必先保存您的工作,然后再继续。

And lastly, although it’s not required, let’s go into XFCE’s control panel, navigate to power settings and disable all standby features. If you don’t use the desktop for a while, XFCE will try to trigger a standby. Although the server normally won’t do anything when it receives this request, it’s better to avoid any unforeseen behaviors altogether.

最后,尽管不是必需的,但让我们进入XFCE的控制面板,导航至电源设置并禁用所有待机功能。 如果您一段时间不使用桌面,则XFCE会尝试触发待机状态。 尽管服务器在收到此请求时通常不会执行任何操作,但最好完全避免任何无法预料的行为。

By going to the Applications menu, then Settings, you can open Power Manager.

通过转到“ 应用程序”菜单,然后转到“设置” ,可以打开“ 电源管理器”

In this application, navigate to the System tab and drag the When inactive for slider all the way to the left. You should now see the text Never under this slider, which means XFCE won’t try to put the system in standby after it’s inactive for a while.

在此应用程序中,导航至“ 系统”选项卡,并将“ 当不活动时”滑块一直拖动到最左侧。 现在,您应该在此滑块下看到文本从不 ,这意味着XFCE在一段时间处于非活动状态后,将不会尝试使系统处于待机状态。

You have now successfully accessed and configured your remote desktop.

现在,您已经成功访问​​并配置了远程桌面。

结论 (Conclusion)

In this tutorial you used X2Go to create a robust and remote GUI-environment for the Debian operating system. Here are a few additional ideas about how to use this desktop. You could centralize your development work by creating a git repository, installing an IDE/code editor like NetBeans or Eclipse, or configuring a web server for testing web applications. You could also enhance your remote desktop with a good backup scheme to make sure that your work environment and important data are safely preserved in case something ever goes wrong. With DigitalOcean, you can also snapshot your Droplets when you’re happy with a certain setup. This way, you can test risky changes and always come back to a known good state in case you break something.

在本教程中,您使用X2Go为Debian操作系统创建了一个健壮的远程GUI环境。 以下是有关如何使用此桌面的一些其他想法。 您可以通过创建git存储库 ,安装IDE /代码编辑器(如NetBeans或Eclipse)或配置用于测试Web应用程序的Web服务器来集中开发工作。 您还可以使用良好的备份方案来增强远程桌面,以确保在出现问题时安全地保存您的工作环境和重要数据。 使用DigitalOcean,您还可以在对特定设置感到满意时对Droplet进行快照 。 这样,您可以测试有风险的更改,并在遇到问题时始终返回到已知的良好状态。

If you’d like to learn more, visit X2Go’s official documentation website.

如果您想了解更多信息,请访问X2Go的官方文档网站

翻译自: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-remote-desktop-with-x2go-on-debian-10

debian 远程桌面

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值