Ubuntu20.04.2无法启动xrdp
服务报错
使用 sudo systemctl start xrdp
命令看到的错误信息:
Job for xrdp.service failed because the control process exited with error code.
See "systemctl status xrdp.service" and "journalctl -xe" for details.
错误详情
使用 sudo systemctl status xrdp
命令看到的错误信息:
xrdp.service - xrdp daemon
Loaded: loaded (/lib/systemd/system/xrdp.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2021-05-07 15:32:11 CST; 5min ago
Docs: man:xrdp(8)
man:xrdp.ini(5)
Process: 913 ExecStartPre=/bin/sh /usr/share/xrdp/socksetup (code=exited, status=0/SUCCESS)
Process: 921 ExecStart=/usr/sbin/xrdp $XRDP_OPTIONS (code=exited, status=1/FAILURE)
5月 07 15:32:10 geekziyu-ubuntu-1 systemd[1]: Starting xrdp daemon...
5月 07 15:32:11 geekziyu-ubuntu-1 xrdp[921]: (921)(140382510946112)[INFO ] address [0.0.0.0] port [3389] mode 3
5月 07 15:32:11 geekziyu-ubuntu-1 xrdp[921]: (921)(140382510946112)[INFO ] listening to port 3389 on 0.0.0.0
5月 07 15:32:11 geekziyu-ubuntu-1 xrdp[921]: (921)(140382510946112)[ERROR] trans_listen_address failed
5月 07 15:32:11 geekziyu-ubuntu-1 xrdp[921]: (921)(140382510946112)[DEBUG] Closed socket 7 (AF_VSOCK cid -1 port -1)
5月 07 15:32:11 geekziyu-ubuntu-1 xrdp[921]: (921)(140382510946112)[ERROR] Failed to start xrdp daemon, possibly address already in use.
5月 07 15:32:11 geekziyu-ubuntu-1 systemd[1]: xrdp.service: Control process exited, code=exited, status=1/FAILURE
5月 07 15:32:11 geekziyu-ubuntu-1 systemd[1]: xrdp.service: Failed with result 'exit-code'.
5月 07 15:32:11 geekziyu-ubuntu-1 systemd[1]: Failed to start xrdp daemon.
使用 journalctl -xe
命令查看的错误信息:
- The unit xrdp.service has entered the 'failed' state with result 'exit-code'.
5月 07 16:17:42 geekziyu-ubuntu-1 systemd[1]: Failed to start xrdp daemon.
-- Subject: xrdp.service 单元已失败
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- xrdp.service 单元已失败。
--
-- 结果为“failed”。
5月 07 16:17:42 geekziyu-ubuntu-1 systemd[1]: Stopping xrdp session manager...
-- Subject: xrdp-sesman.service 单元已开始停止操作
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- xrdp-sesman.service 单元已开始停止操作。
5月 07 16:17:42 geekziyu-ubuntu-1 systemd[1]: xrdp-sesman.service: Control process exited, code=exited, status=1/FAILURE
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- An ExecStop= process belonging to unit xrdp-sesman.service has exited.
--
-- The process' exit code is 'exited' and its exit status is 1.
5月 07 16:17:42 geekziyu-ubuntu-1 xrdp-sesman[2393]: (2393)(140390371907136)[INFO ] shutting down sesman 1
5月 07 16:17:42 geekziyu-ubuntu-1 xrdp-sesman[2393]: (2393)(140390371907136)[DEBUG] Closed socket 7 (AF_INET6 ::1 port 3350)
5月 07 16:17:42 geekziyu-ubuntu-1 systemd[1]: xrdp-sesman.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit xrdp-sesman.service has entered the 'failed' state with result 'exit-code'.
5月 07 16:17:42 geekziyu-ubuntu-1 systemd[1]: Stopped xrdp session manager.
-- Subject: xrdp-sesman.service 单元已结束停止操作
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- xrdp-sesman.service 单元已结束停止操作。
使用 sudo systemctl status xrdp-sesman
命令查看
xrdp-sesman.service - xrdp session manager
Loaded: loaded (/lib/systemd/system/xrdp-sesman.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/xrdp-sesman.service.d
└─override.conf
Active: failed (Result: exit-code) since Fri 2021-05-07 16:17:42 CST; 13min ago
Docs: man:xrdp-sesman(8)
man:sesman.ini(5)
Process: 2392 ExecStartPre=/bin/sleep 20 (code=exited, status=0/SUCCESS)
Process: 2393 ExecStart=/usr/sbin/xrdp-sesman $SESMAN_OPTIONS (code=exited, status=0/SUCCESS)
Process: 2403 ExecStop=/usr/sbin/xrdp-sesman $SESMAN_OPTIONS --kill (code=exited, status=1/FAILURE)
Main PID: 2393 (code=exited, status=0/SUCCESS)
5月 07 16:17:41 geekziyu-ubuntu-1 systemd[1]: Started xrdp session manager.
5月 07 16:17:41 geekziyu-ubuntu-1 xrdp-sesman[2393]: (2393)(140390371907136)[DEBUG] libscp initialized
5月 07 16:17:41 geekziyu-ubuntu-1 xrdp-sesman[2393]: (2393)(140390371907136)[INFO ] starting xrdp-sesman with pid 2393
5月 07 16:17:41 geekziyu-ubuntu-1 xrdp-sesman[2393]: (2393)(140390371907136)[INFO ] listening to port 3350 on 127.0.0.1
5月 07 16:17:42 geekziyu-ubuntu-1 systemd[1]: Stopping xrdp session manager...
5月 07 16:17:42 geekziyu-ubuntu-1 systemd[1]: xrdp-sesman.service: Control process exited, code=exited, status=1/FAILURE
5月 07 16:17:42 geekziyu-ubuntu-1 xrdp-sesman[2393]: (2393)(140390371907136)[INFO ] shutting down sesman 1
5月 07 16:17:42 geekziyu-ubuntu-1 xrdp-sesman[2393]: (2393)(140390371907136)[DEBUG] Closed socket 7 (AF_INET6 ::1 port 3350)
5月 07 16:17:42 geekziyu-ubuntu-1 systemd[1]: xrdp-sesman.service: Failed with result 'exit-code'.
5月 07 16:17:42 geekziyu-ubuntu-1 systemd[1]: Stopped xrdp session manager.
问题分析
现在的主要问题就是 xrdp 和 xrdp-sesman 都启动失败了,我也找了好多办法,发现了一个比较靠谱的解决方法 click here
解决方法
以下操作均在 Ubuntu 虚拟机 上完成:
1.卸载 xrdp
sudo apt-get purge xrdp
之前安装的 xrdp
总是启动不了,所以先卸载
2.下载 xrdp-installer-1.2.3.zip
如果是 Ubuntu 这类可视化 Linux 系统,打开自带的 FireFox 浏览器,输入 http://www.c-nergy.be/products.html
如果是非可视化的,可以使用 wget 命令下载
wget https://www.c-nergy.be/downloads/xrdp-installer-1.2.3.zip
一般来说,这个包会自动下载到 ~/下载
目录下。
3.解压缩
进入文件所在目录,并解压缩文件。
cd ~/下载
unzip xrdp-installer-1.2.3.zip
解压完成后将得到 xrdp-installer-1.2.3.sh
4. 修改脚本为可以执行脚本
chmod +x ~/Downloads/xrdp-installer-1.2.3.sh
5. 执行脚本
./xrdp-installer-1.2.3.sh
6.重启 xrdp
注意,需要切换到 root 用户,否则启动时仍然会报错
$ su root
$ systemctl restart xrdp
7.重启 xrdp-sesman
同理,在重启 xrdp 成功后,重启 xrdp-sesman
$ systemctl restart xrdp-sesman
现在就解决了 Ubuntu20.04.2 无法启动 xrdp 的问题了~
2022-05-17 最新补充
执行以下命令重启时失败:
su root
sudo systemctl restart xrdp xrdp-sesman
systemctl status xrdp
查看 xrdp 启动失败原因:
Can't open PID file /run/xrdp/xrdp.pid (yet?) after start: Operation not permitted
问题分析:打开 /run/xrdp/xrdp.pid 文件时出错,操作没有权限?我都以 root 用户来执行了,怎么会没权限呢?
ls -al /run | grep xrdp
找不到
/run/xrdp
文件夹,然后我就想干脆我给他创建一个试试吧!
问题解决:
cd /run
sudo mkdir xrdp
然后再次执行
systemctl restart xrdp xrdp-sesman
,启动成功!
2022-06-28 最新补充
先执行启动 xrdp-sesman 的命令:
sudo systemctl restart xrdp-sesman
,再执行创建 /run/xrdp 文件夹的命令:
cd /run
sudo mkdir xrdp
最后执行重启 xrdp 的命令:
sudo systemctl restart xrdp
我用这个步骤解决反复执行 mkdir xrdp
和 systemctl restart xrdp
仍然无法启动 xrdp 的问题。