# 在Ubuntu桌面服务器上快速安装XRdp

**URL:** <https://forum.rainyun.com/t/topic/8535>\
**Category:** 软件分享\
**Created:** [2024 年7 月 8 日 05:52 UTC](https://forum.rainyun.com/t/topic/8535 "2024-07-08T05:52:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

作者： ![luyii](https://forum.rainyun.com/user_avatar/forum.rainyun.com/luyii/32/5047_2.png) [@luyii](https://forum.rainyun.com/u/luyii)\
发布日期： [2024 年7 月 8 日 05:52 UTC](https://forum.rainyun.com/t/topic/8535/1 "2024-07-08T05:52:37Z")

</div>

[前往我的网站阅读，体验更佳 ——\>[https://luyii.cn/archives/IMxvs7Xo](https://luyii.cn/archives/IMxvs7Xo)]

## 文章被雨云论坛搞得很奇怪，出问题请 前往我的网站阅读[https://luyii.cn/archives/IMxvs7Xo](https://luyii.cn/archives/IMxvs7Xo)

教程以结合个人经验编写，虽然已经过错误检查，但是仍可能存在问题，若你发现了问题，请反馈到root@luyii.cn，谢谢！

**本教程中示例使用"$$"为变量，示例：** `$普通用户，上面创建的$@$你的服务器地址$` **中，如果你的用户名为luyii，地址为127.0.0.1，则** `$普通用户，上面创建的$@$你的服务器地址$` **为** `luyii@127.0.0.1`

# 1. 准备工作

确保已经在Ubuntu上安装了官方风格GUI桌面，不支持其他桌面

# 2. 获取所需文件

- 在Ubuntu上，虽然可以直接通过`sudo apt install xrdp` 直接安装XRdp，但是这种安装方法太过于繁琐，需要手动配置各项文件，这里我们直接使用官方脚本安装

## 2.1 创建普通用户

由于XRdp不支持root用户安装与登录，所以我们需要创建一个普通用户

如果你的服务器已经有非root管理员用户，请跳至[2.2](https://forum.rainyun.com/archives/IMxvs7Xo#2.2%20%E5%87%86%E5%A4%87%E8%84%9A%E6%9C%AC)步

### 2.1.1 连接服务器

使用你喜欢的SSH工具连接到服务器的Root用户，这里以OpenSSH为例

```auto
ssh root@$你的服务器地址$
输入你的密码（不会显示已输入内容，故意的）
(如果你是第一次连接，将会询问你是否保存密钥，输入yes即可)

```

示例：

```auto
C:\Users\user>ssh root@$你的服务器地址$
The authenticity of host '$你的服务器地址$($你的服务器地址$)' can't be established.
ED25519 key fingerprint is SHA256: ******/*****.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '$你的服务器地址

```

### 2.1.2 创建普通用户

在SSH中执行`sudo adduser <usernam>`

示例：\*由ChatGPT模拟，与实际可能有差别

```auto
$ sudo adduser xrdp
Adding user `xrdp' ...
Adding new group `xrdp' (1001) ...
Adding new user `xrdp' (1001) with group `xrdp' ...
Creating home directory `/home/xrdp' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for xrdp
Enter the new value, or press ENTER for the default
	Full Name []:
	Room Number []:
	Work Phone []:
	Home Phone []:
	Other []:
Is the information correct? [Y/n] Y

```

## 2.2 准备脚本

### 2.2.1 下载文件

使用`wget https://c-nergy.be/downloads/xRDP/xrdp-installer-1.5.1.zip` 下载

示例：

```auto
root@instance-qpSFyw5o:~# wget https://c-nergy.be/downloads/xRDP/xrdp-installer-1.5.1.zip
--2024-07-08 12:51:21-- https://c-nergy.be/downloads/xRDP/xrdp-installer-1.5.1.zip
正在解析主机 c-nergy.be (c-nergy.be)... 46.30.213.4, 2a02:2350:5:10a:20:9ad9:e660:36ac
正在连接 c-nergy.be (c-nergy.be)|46.30.213.4|:443... 已连接。
已发出 HTTP 请求，正在等待回应... 200 OK
长度： 13323 (13K) [application/zip]
正在保存至: ‘xrdp-installer-1.5.1.zip’

xrdp-installer-1.5.1.zip 100%[=================================================>] 13.01K --.-KB/s 用时 0s

2024-07-08 12:51:22 (149 MB/s) - 已保存 ‘xrdp-installer-1.5.1.zip’ [13323/13323])

root@instance-qpSFyw5o:~#

```

### 2.2.2 解压文件

使用`unzip xrdp-installer-1.5.1.zip` 解压

示例：

```auto
root@instance-qpSFyw5o:~# unzip xrdp-installer-1.5.1.zip
Archive: xrdp-installer-1.5.1.zip
  inflating: xrdp-installer-1.5.1.sh
root@instance-qpSFyw5o:~#

```

### 2.2.3 设置为可执行文件

注意：脚本不可以直接使用`sh xrdp-installer-1.5.1.sh` 执行

使用`chmod +x xrdp-installer-1.5.1.sh` 设置

示例：

```auto
root@instance-qpSFyw5o:~# chmod +x xrdp-installer-1.5.1.sh
root@instance-qpSFyw5o:~# 

```

# 3. 执行脚本

## 3.1 重新使用普通用户登录

使用你喜欢的SSH工具连接到服务器的普通用户

```auto
ssh $普通用户，上面创建的$@$你的服务器地址$
输入你的密码（不会显示已输入内容，故意的）
(如果你是第一次连接，将会询问你是否保存密钥，输入yes即可)

```

示例：

```auto
C:\Users\user>ssh $普通用户，上面创建的$@$你的服务器地址$
The authenticity of host '$你的服务器地址$($你的服务器地址$)' can't be established.
ED25519 key fingerprint is SHA256: ******/*****.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '$你的服务器地址

```

## 3.2 执行脚本

使用`./xrdp-installer-1.5.1.sh` 执行

示例：

```auto
root@instance-qpSFyw5o:~# ./xrdp-installer-1.5.1.sh

   !-----------------------------------------------------------------!
   ! xrdp-installer-1.5.1 Script !
   ! Support Ubuntu and Debian Distribution !
   ! Written by Griffon - June 2024 - www.c-nergy.be !
   ! !
   ! For Help and Syntax, type ./xrdp-installer-1.5.1.sh -h !
   ! !
   !-----------------------------------------------------------------!

   !----------------------------------------------------------------!
   ! Disclaimer !
   ! !! Script provided AS IS. Use it at your own risk.!! !
   !----------------------------------------------------------------!

   |-| Checking if script has run at least once...
       |-| Script has already run. Detected mode...: standard

       |-| Detected Installation via ssh....

  !--------------------------------------------------------------!
  ! Your are using the xrdp-installer script via ssh connection !
  ! The script will proceed....but might not work !! !
  ! Trying to detect Desktop interface in use... !
  !--------------------------------------------------------------!

2
1) ubuntu
2) ubuntu-xorg
Please specify which DE you are using...:

```

## 3.3 选择环境

在3.2中执行脚本会输出询问：

```auto
1) ubuntu
2) ubuntu-xorg
Please specify which DE you are using...:

```

如果使用SSH，选择1

如果使用VNC连接Xorg桌面后使用SSH，选择2

示例：\*由ChatGPT生成，请勿参考使用"^^^"框起的输出内容

```auto
$普通用户，上面创建的$@$你的服务器地址$:~# ./xrdp-installer-1.5.1.sh

   !-----------------------------------------------------------------!
   ! xrdp-installer-1.5.1 Script !
   ! Support Ubuntu and Debian Distribution !
   ! Written by Griffon - June 2024 - www.c-nergy.be !
   ! !
   ! For Help and Syntax, type ./xrdp-installer-1.5.1.sh -h !
   ! !
   !-----------------------------------------------------------------!

   !----------------------------------------------------------------!
   ! Disclaimer !
   ! !! Script provided AS IS. Use it at your own risk.!! !
   !----------------------------------------------------------------!

   |-| Checking if script has run at least once...
       |-| Script has already run. Detected mode...: standard

       |-| Detected Installation via ssh....

  !--------------------------------------------------------------!
  ! Your are using the xrdp-installer script via ssh connection !
  ! The script will proceed....but might not work !! !
  ! Trying to detect Desktop interface in use... !
  !--------------------------------------------------------------!

2
1) ubuntu
2) ubuntu-xorg
Please specify which DE you are using...:1
^^^
Extracting XRDP package...
Verifying checksum...
Checksum OK.
Installing XRDP...
XRDP installed successfully.

Starting XRDP service...
XRDP service started.

Installation complete.
^^^

```

## 3.4\* 如果你正在使用VNC连接Xorg桌面使用SSH，请注销会话，连接SSH不受影响，关闭即可

# 4. 连接

## 4.1 在Windows电脑中按下"Win"+R，打开”运行“

![|392pxx222px](https://forum.rainyun.com/upload/image-lxwg.png)

## 4.2 输入”mstsc“并回车

![|406pxx233px](https://forum.rainyun.com/upload/image-lutq.png)

## 4.3 输入你服务器地址并回车

![|441pxx294px](https://forum.rainyun.com/upload/image-rulj.png)

如果出现证书警告窗口，直接确定即可（缺图）

# 5. 完成！

![|100%x100%](https://forum.rainyun.com/upload/image-afpl.png)

# 来自ChatGPT的认可： ![|100%x100%](https://forum.rainyun.com/upload/image-fdem.png)
