Tips/Ubuntu/リモートアクセス設定 のバックアップ(No.5)



目的

以下の2手段でリモートアクセスできるようにする

  • ssh
  • Remote Desktop

前提条件

Ubuntu 18.04.3 LTS (Bionic Beaver)

ssh設定

  1. sshをインストールする
    sudo apt-get install ssh
  2. sshdサービスを起動する
    systemctl start sshd

vnc設定

vncを導入しgnome desktopに入れるようにする

  1. vncおよびgnome desktop関連パッケージをインストールする
    sudo apt install xserver-xorg-core tigervnc-standalone-server tigervnc-xorg-extension tigervnc-viewer -y
    sudo apt install ubuntu-gnome-desktop -y
  2. gnome desktop managerサービスを起動する
    sudo systemctl start gdm

RemoteDesktop設定

  1. xrdpインストール
    sudo apt install -y xrdp
  2. new_cursorsを無効にする
    sudo sed -e 's/^new_cursors=true/new_cursors=false/g' \
             -i /etc/xrdp/xrdp.ini
  3. xrdpサービスを起動
    sudo systemctl restart xrdp
  4. ubuntu向け設定をロードするよう設定
    D=/usr/share/ubuntu:/usr/local/share:/usr/share:/var/lib/snapd/desktop
    cat <<EOF > ~/.xsessionrc
    export GNOME_SHELL_SESSION_MODE=ubuntu
    export XDG_CURRENT_DESKTOP=ubuntu:GNOME
    export XDG_DATA_DIRS=${D}
    export XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg
    EOF
  5. Authentication Requiredダイアログの回避
    cat <<EOF | \
      sudo tee /etc/polkit-1/localauthority/50-local.d/xrdp-color-manager.pkla
    [Netowrkmanager]
    Identity=unix-user:*
    Action=org.freedesktop.color-manager.create-device
    ResultAny=no
    ResultInactive=no
    ResultActive=yes
    EOF
  6. polkitサービスの再起動
    sudo systemctl restart polkit
    sudo reboot