• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

Ubuntu20.04运行远程桌面

武飞扬头像
weixin_44282127
帮助3

1、安装好Ubuntu20.04之后,默认情况下是不允许以root用户登录的,只能以其他用户登录系统中,然后su到root用户下进行操作。
        1.1、设置好root账户密码:sudo passwd root
        1.2、切换root用户登录操作系统:su root
        1.3、修改/etc/gdm3/daemon.conf文件
     [security]下面新增一行AllowRoot = true
        1.4、修改/etc/pam.d/gdm-password
    注释掉下面内容
    #auth required pam_succeed_if.so user != root quiet_success
    然后重启操作系统,就可以使用root用户登录操作系统了。

2、如果出现方向键和退格键失灵,优先解决Vi编辑器的方向键和退格键失灵的问题
     测试中发现Vi编辑器在文本输入模式时,不能正确使用方向键和退格键,解决方法:用gedit /etc/vim/vimrc.tiny,
     输入以下两行:set nocompatible 和set backspace=2这样就切换到非兼容模式,并且退格键也可以正常使用了。 

3、配置网络源,执行两条命令替换源文件内容

sudo sed -i "s@http://.*archive.ubuntu.com@http://repo.huaweicloud.com@g" /etc/apt/sources.list
sudo sed -i "s@http://.*security.ubuntu.com@http://repo.huaweicloud.com@g" /etc/apt/sources.list

可执行cat /etc/apt/source.list,查看替换后的内容(以下内容),替换完之后apt update,
# deb cdrom:[Ubuntu 20.04.1 LTS _Focal Fossa_ - Release amd64 (20200731)]/ focal main restricted
 
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb https://repo.huaweicloud.com/ubuntu/ focal main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal main restricted
 
## Major bug fix updates produced after the final release of the
## distribution.
deb https://repo.huaweicloud.com/ubuntu/ focal-updates main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates main restricted
 
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb https://repo.huaweicloud.com/ubuntu/ focal universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal universe
deb https://repo.huaweicloud.com/ubuntu/ focal-updates universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates universe
 
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates multiverse
 
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb https://repo.huaweicloud.com/ubuntu/ focal-backports main restricted universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
 
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu focal partner
# deb-src http://archive.canonical.com/ubuntu focal partner
 
deb https://repo.huaweicloud.com/ubuntu/ focal-security main restricted
# deb-src http://security.ubuntu.com/ubuntu focal-security main restricted
deb https://repo.huaweicloud.com/ubuntu/ focal-security universe
# deb-src http://security.ubuntu.com/ubuntu focal-security universe 
# deb-src http://security.ubuntu.com/ubuntu focal-security multiverse
 
# This system was installed using small removable media
# (e.g. netinst, live or single CD). The matching "deb cdrom"
# entries were disabled at the end of the installation process.
# For information about how to configure apt package sources,

4、以root身份通过ssh登录操作系统,步骤3已经配好网络源,先下载ssh服务,sudo apt install ssh,
     之后修改/etc/ssh/sshd_config,将#PermitRootLogin prohibit-password,修改为PermitRootLogin yes,
     接着重启ssh服务:service sshd restart ,之后就可以以root用户ssh登录了。

5、开启远程桌面功能:
     5.1、安装vnc服务:sudo apt-get install tightvncserver
     5.2、安装xrdp服务:sudo apt-get install xrdp(注意VNC与xrdp服务安装顺序不可以颠倒,否则可能在登陆的时候报错Error Problem connecting)
     5.3、配置xrdp服务:/etc/startwm.sh ,加入echo unity>~/.xsession保存后重启xrdp服务:sudo service xrdp restart
     5.4、配置Ubuntu桌面共享选项:在搜索栏搜索(DeskTop Sharing),开启最后一个和倒数第三个选项,倒数第三个选项勾选密码并设置
     5.5、终端输入dconf-editor命令,会出现一个窗口,在编辑窗口 依次选择org–gnome–desktop–remote-access把里
             面的require-encryption取消勾选,(如果提示没有安装dconf-editor,则需要先安装dconf-editor:apt install dconf-editor)
到这一步,已经可以远程登录普通用户了

6、创建新用户并开启sudo权限
     6.1、添加新用户:sudo adduser 用户名
     6.2、为用户赋权:vi /etc/sudoers,在root ALL=(ALL) ALL后面添加新的一行用户名 ALL=(ALL) ALL ,保存并退出(只读文件,输入:wq!),添加超级用户权限完成。

7、root账户登录远程桌面黑屏时,编辑文件sudo vim /etc/xrdp/startwm.sh,在文件的if test -r /etc/profile; then前面添加
     unset DBUS_SESSION_BUS_ADDRESS
     unset XDG_RUNTIME_DIR两行保存退出即可

注意:普通用户要使用源安装时,需要在命令前加上sudo,自己创建的文件会保存在/home/目录下对应的用户名文件夹下。源或者自己安装的工具包(软件包)
在所有用户下都是共用的

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhfecgki
系列文章
更多 icon
同类精品
更多 icon
继续加载