2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Kali Linux on Raspberry Pi にRDP接続すると黒い画面になる

Last updated at Posted at 2021-06-27

前提

Raspberry Pi 4 Model B にKali Linuxをインストールしています。
Kaliインストール用のイメージは公式サイトから取得しています。

また、Windowsからssh接続ができている状態です。Macからでも同様の症状です。

問題

ssh接続からコマンドでrdp関係のソフトをインストールすれば動くはず!

bash
apt install kali-desktop-xfce xorg xrdp tigervnc* xfe4 dbus-x11 xorgxrdp

ところが、ログイン後に黒い画面になってしまい、しばらくすると勝手に接続が切れます。

image.png
▼▼▼▼▼▼
image.png
▼▼▼▼▼▼
image.png

Raspberry Pi を再起動して、最初だけC:\WINDOWS\system32\mstsc.exeで接続できるのですが、なぜか2度目からこのように真っ黒になり、困っていました。

検証した項目

Windows側からnmap <ip-of-kali-linux>を実行してみる。
※(<ip-of-kali-linux>はプレースホルダ)

output
Starting Nmap 7.80 ( https://nmap.org ) at 2021-06-28 03:22 ???? (?W???)
Nmap scan report for <ip-of-kali-linux>
Host is up (0.0081s latency).
Not shown: 998 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
3390/tcp open  dsc
MAC Address: DC:A6:32:FD:16:F6 (Raspberry Pi Trading)

ご覧のように、ちゃんとssh用のポートとRDP用のポートは開いています。

kali側からsudo netstat -plnt | grep rdpを実行してみる。

output
tcp        0      0 0.0.0.0:3390            0.0.0.0:*               LISTEN      197638/xrdp
tcp6       0      0 :::3350                 :::*                    LISTEN      197627/xrdp-sesman

このコマンドでもkali側のポートが開いていることが分かります。

kali側でtail -f /var/log/syslogを実行しながらWindows側からRDP接続を試す。

[WARN ] local keymap file for 0xe0010411 found and doesn't match built in keymap, using local keymap file
[ERROR] xrdp_mm_connect_chansrv: connect failed trying again...
[ERROR] xrdp_mm_connect_chansrv: error in trans_connect chan

怪しかった部分は、たった3行。WARNとかERRORとかいう文字列はここ以外に見つからない。しかし、これでGooglっても何も収穫無し。

結果

journalctl -xeを実行すると、Invalid MIT-MAGIC-COOKIE-1 keyError: cannot open display ':0'というエラーが出ていたので、これで検索してみました。結果、ここで見つけた方法で回復しました。

それは、下記のコマンドです。

export DISPLAY=desktop:0
xhost +local:

xhostのコマンドリファレンスはこちらです。

RDP画面

素晴らしい。Rasberry Piでリモートとか重たそうでしたが、意外とサクサクです。高級SDカードを使ってるからかもです。

image.png
image.png

xhost

環境変数DISPLAYを設定していないと、下記のようなエラーが帰ってきました。

❯ sudo xhost
xhost:  unable to open display ""

to be continue...

後から見つけましたが、このあたりが参考になりそうなので、関連ツールを調べてみようと思います。

Excelsior!

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?