一、 Ubuntu12-22通用,安装Xfce图形界面(由于ubuntu12的源已经失效,目前没法验证ubuntu12了,其他的ubuntu偶数版本我都验证过)
参考https://learn.microsoft.com/en-us/azure/virtual-machines/linux/use-remote-desktop?tabs=azure-cli 第1步 sudo su root apt-get update apt-get install python-software-properties xfce4 xfce4-goodies
如果python-software-properties不存在,就用software-properties-common替代python-software-properties
如果不需要出现下面这种交互式界面
那就在apt-get install 前面加DEBIAN_FRONTEND=noninteractive
例如把apt-get install software-properties-common xfce4 xfce4-goodies改成DEBIAN_FRONTEND=noninteractive apt-get install software-properties-common xfce4 xfce4-goodies
第2步 apt-get install net-tools xrdp firefox xfonts-wqy sysv-rc-conf -y(≥ubuntu18.04执行apt-get install net-tools xrdp firefox xfonts-wqy -y)
执行时如果不识别sysv-rc-conf (≥ubuntu18.04不支持sysv-rc-conf ,不用动源)
代码语言:javascript复制vim /etc/apt/sources.list
在软件源sources.list文件末尾添加如下文本
代码语言:javascript复制deb http://mirrors.tencentyun.com/ubuntu/ trusty main universe restricted multiverse
解析不了内网域名的话,把/etc/apt/sources.list里的mirrors.tencentyun.com替换为mirrors.sohu.com或mirrors.tuna.tsinghua.edu.cn
然后apt-get update(如果Ubuntu换源后,更新提示GPG error缺少公钥,参考https://blog.csdn.net/qq_38889662/article/details/108205364 执行2句命令)
代码语言:javascript复制
执行2句命令后连续执行3遍apt-get update,发现只有Warning了,忽略即可
然后重新执行apt-get install net-tools xrdp firefox xfonts-wqy sysv-rc-conf -y (≥ubuntu22.04执行apt-get install net-tools xrdp firefox xfonts-wqy -y)
第3步 设置支持中文显示 执行localectl set-locale LANG=en_US.utf8 第4步 sysv-rc-conf xrdp on(≥ubuntu22.04执行systemctl enable xrdp)
echo xfce4-session >~/.xsession
adduser xrdp ssl-cert(≥ubuntu18.04需要执行这句)
service xrdp restart
netstat -tunlp|grep 3389
执行 netstat -tunlp 查看远程端口是监听状态就可以用windows里的mstsc来远程了,跟远程windows服务器的方式一模一样
代码语言:javascript复制设置默认不进入图形界面
systemctl set-default multi-user.target
设置后重启机器生效
代码语言:javascript复制Ubuntu图形界面root登录出现“sorry, that didn't work please try again”
https://www.jianshu.com/p/890521a4c081
vim /etc/pam.d/gdm-autologin
注释行 "auth requied pam_succeed_if.so user != root quiet success"
vim /etc/pam.d/gdm-password
注释行 "auth requied pam_succeed_if.so user != root quiet success"
注释后重启机器生效
代码语言:javascript复制Ubuntu系统安装中文字体(不是必须的,如果浏览器中文网站比如百度乱码,是需要安装下的),如果有需要,参考文档末尾
apt-get install language-pack-zh*
apt-get install chinese*
apt-get install fonts-arphic-ukai fonts-arphic-uming fonts-ipafont-mincho fonts-ipafont-gothic fonts-unfonts-core
安装后重启机器生效
验证能否远程,到这一步一般都可以了,如果不行
vim /etc/xrdp/xrdp.ini 修改port这一步不是必须的,port 3389改为port 33899(或别的1025-65535之间的端口,注意新端口要在安全组入站规则放行) 如果没有ssl_protocols=xxx,那么在crypt_level=下面添加一行 ssl_protocols=TLSv1, TLSv1.1, TLSv1.2(看下crypt_level=后面是high还是low,如果是low,改成high) 如果有ssl_protocols=xxx,确保等号右边是TLSv1, TLSv1.1, TLSv1.2
然后重启机器
如果远程时报 login failed for display 0,参考下这篇文档看看能不能解决
https://askubuntu.com/questions/1164456/18-04-3-lts-xrdp-login-failed-for-display-0
如果远程时,闪一下就退出了,需要分析日志,例如情况一:
grep ERROR /var/log/xrdp.log
[20220929-23:36:44] [ERROR] Cannot read private key file /etc/xrdp/key.pem: Permission denied
[20220929-23:36:54] [ERROR] Cannot read private key file /etc/xrdp/key.pem: Permission denied
[20220929-23:36:55] [ERROR] Cannot read private key file /etc/xrdp/key.pem: Permission denied
[20220929-23:36:55] [ERROR] Cannot read private key file /etc/xrdp/key.pem: Permission denied
报上面这个错需要执行adduser xrdp ssl-cert
这是个bug,
https://github.com/neutrinolabs/xrdp/issues/1169
https://wiki.iphoster.net/wiki/RDP_-_ERROR_-_Cannot_read_private_key_file_/etc/xrdp/key.pem_-_Permission_denied
如果远程时,闪一下就退出了,需要分析日志,例如情况二:
grep socket /var/log/xrdp-sesman.log
[20221008-15:23:46] [CORE ] starting sesman with pid 1139
[20221008-15:23:46] [INFO ] listening...
[20221008-15:24:51] [INFO ] scp thread on sck 7 started successfully
[20221008-15:24:52] [INFO ] created session (access granted): username root, ip 111.206.145.22:2748 - socket: 7
[20221008-15:24:52] [INFO ] starting Xvnc session...
[20221008-15:24:52] [INFO ] starting xrdp-sessvc - xpid=1638 - wmpid=1637
[20221008-15:24:52] [INFO ] terminated session: username root, display :10.0, session_pid 1636, ip 111.206.145.22:2748 - socket: 7
[20221008-15:30:48] [CORE ] starting sesman with pid 1085
[20221008-15:30:48] [INFO ] listening...
[20221008-15:31:26] [INFO ] scp thread on sck 7 started successfully
[20221008-15:31:26] [INFO ] created session (access granted): username root, ip 111.206.145.22:3211 - socket: 7
[20221008-15:31:26] [INFO ] starting Xvnc session...
[20221008-15:31:26] [INFO ] starting xrdp-sessvc - xpid=1588 - wmpid=1587
[20221008-15:31:26] [INFO ] terminated session: username root, display :10.0, session_pid 1586, ip 111.206.145.22:3211 - socket: 7
这种情况需要参考https://blog.csdn.net/weixin_36411269/article/details/116883296 将下面两行参数设置追加到/etc/xrdp/sesman.ini的[Xvnc]配置中
param8=-SecurityTypes
param9=None
采取以上方法后重启机器即可
二、Ubuntu系统安装中文字体(不是必须的,如果浏览器中文网站比如百度乱码,是需要安装下的)
参考https://help.accusoft.com/PrizmDoc/v12.2/HTML/Installing_Asian_Fonts_on_Ubuntu_and_Debian.html
apt-get install language-pack-zh*
apt-get install chinese*
apt-get install fonts-arphic-ukai fonts-arphic-uming fonts-ipafont-mincho fonts-ipafont-gothic fonts-unfonts-core
执行时如果报The following packages have unmet dependencies:
libqtgui4 : Depends: libpng12-0 (>= 1.2.13-4) but it is not going to be installed
参考https://launchpad.net/~linuxuprising/ archive/ubuntu/libpng12
参考https://www.linuxuprising.com/2018/05/fix-libpng12-0-missing-in-ubuntu-1804.html
执行这3句后再安装中文字体(适用ubuntu18/20,不适用ubuntu22)
代码语言:javascript复制add-apt-repository ppa:linuxuprising/libpng12
apt update
apt install libpng12-0
执行时如果报The following packages have unmet dependencies:
usrmerge : Conflicts: libpng12-0 (< 1.2.54-4~) but 1.2.50-1ubuntu2 is to be installed
换着顺序试一下
代码语言:javascript复制apt-get install chinese*
apt-get install language-pack-zh*
apt-get install fonts-arphic-ukai fonts-arphic-uming fonts-ipafont-mincho fonts-ipafont-gothic fonts-unfonts-core