--- lang: ja-jp breaks: true --- # Ubuntu にリモートデスクトップでログイン xrdp 2021-04-29 > 第621回 Ubuntu 20.04 LTSでxrdpを使用する > https://gihyo.jp/admin/serial/01/ubuntu-recipe/0621 #### xrdp をインストール ```shell= $ sudo apt install xrdp ``` ```shell= $ vim enhanced-session-mode.sh ``` ```shell= #!/bin/sh # Add script to setup the ubuntu session properly if [ ! -e /etc/xrdp/startubuntu.sh ]; then cat >> /etc/xrdp/startubuntu.sh << EOF #!/bin/sh export GNOME_SHELL_SESSION_MODE=ubuntu export XDG_CURRENT_DESKTOP=ubuntu:GNOME exec /etc/xrdp/startwm.sh EOF chmod a+x /etc/xrdp/startubuntu.sh fi sed -i_orig -e 's/startwm/startubuntu/g' /etc/xrdp/sesman.ini # rename the redirected drives to 'shared-drives' sed -i -e 's/FuseMountName=thinclient_drives/FuseMountName=shared-drives/g' /etc/xrdp/sesman.ini # Changed the allowed_users sed -i_orig -e 's/allowed_users=console/allowed_users=anybody/g' /etc/X11/Xwrapper.config # Configure the policy xrdp session cat > /etc/polkit-1/localauthority/50-local.d/45-allow-colord.pkla <<EOF [Allow Colord all Users] Identity=unix-user:* Action=org.freedesktop.color-manager.create-device;org.freedesktop.color-manager.create-profile;org.freedesktop.color-manager.delete-device;org.freedesktop.color-manager.delete-profile;org.freedesktop.color-manager.modify-device;org.freedesktop.color-manager.modify-profile ResultAny=no ResultInactive=no ResultActive=yes EOF # https://askubuntu.com/questions/1193810/authentication-required-to-refresh-system-repositories-in-ubuntu-19-10 cat > /etc/polkit-1/localauthority/50-local.d/46-allow-update-repo.pkla<<EOF [Allow Package Management all Users] Identity=unix-user:* Action=org.freedesktop.packagekit.system-sources-refresh ResultAny=yes ResultInactive=yes ResultActive=yes EOF ``` #### 権限をつけて実行 ```shell= chmod u+x enhanced-session-mode.sh sudo ./enhanced-session-mode.sh ``` #### 再起動する ```shell= # sudo reboot now ``` #### 状態表示 以下の様に表示されれば、接続できるはず。 ```shell= $ systemctl status xrdp.service ● xrdp.service - xrdp daemon Loaded: loaded (/lib/systemd/system/xrdp.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2021-04-29 02:46:01 JST; 3min 51s ago Docs: man:xrdp(8) man:xrdp.ini(5) Process: 650 ExecStartPre=/bin/sh /usr/share/xrdp/socksetup (code=exited, status=0/SUCCESS) Process: 665 ExecStart=/usr/sbin/xrdp $XRDP_OPTIONS (code=exited, status=0/SUCCESS) Main PID: 668 (xrdp) Tasks: 1 (limit: 4503) Memory: 3.4M CGroup: /system.slice/xrdp.service └─668 /usr/sbin/xrdp 4月 29 02:46:00 vm-ubuntu xrdp[665]: (665)(140005202818880)[INFO ] address [0.0.0.0] port [3389] mode 1 4月 29 02:46:00 vm-ubuntu xrdp[665]: (665)(140005202818880)[INFO ] listening to port 3389 on 0.0.0.0 4月 29 02:46:00 vm-ubuntu xrdp[665]: (665)(140005202818880)[INFO ] xrdp_listen_pp done 4月 29 02:46:00 vm-ubuntu xrdp[665]: (665)(140005202818880)[DEBUG] Closed socket 7 (AF_INET6 :: port 3389) 4月 29 02:46:00 vm-ubuntu systemd[1]: xrdp.service: Can't open PID file /run/xrdp/xrdp.pid (yet?) after start: Operation not permitted 4月 29 02:46:01 vm-ubuntu systemd[1]: Started xrdp daemon. 4月 29 02:46:02 vm-ubuntu xrdp[668]: (668)(140005202818880)[INFO ] starting xrdp with pid 668 4月 29 02:46:02 vm-ubuntu xrdp[668]: (668)(140005202818880)[INFO ] address [0.0.0.0] port [3389] mode 1 4月 29 02:46:02 vm-ubuntu xrdp[668]: (668)(140005202818880)[INFO ] listening to port 3389 on 0.0.0.0 4月 29 02:46:02 vm-ubuntu xrdp[668]: (668)(140005202818880)[INFO ] xrdp_listen_pp done ``` #### Windows10からリモートデスクトップで接続 ![](https://i.imgur.com/x3Fki66.jpg) ###### tags: `Ubuntu` `xrdp`