0
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?

AWS EC2 linux2にRDP接続がスムーズに行かなかった件

Last updated at Posted at 2024-07-04

はじめに

AWS上にデスクトップ環境を構築する必要が生じたので、MATE Desktop Enviromentが導入済みのAMIインスタンスを立ち上げて、以下の記事を参照しつつRDPで接続しようと思いましたが、RDP接続で少し躓いたのでまとめます。

参考記事

問題

Amazon Linux 2 with.NET6, PowerShell, Mono, and MATE Desktop Environmentインスタンスを立ち上げるところまでは、以下の参考記事の手順に従って実施。

参考記事によればこれだけでRDP接続できそうですが、実際には接続できませんでした。(クライアントはMicrosoft Remote Desktopを使用。)

下の部分をダブルクリックすると
Untitled3.png

この画面が表示され、Connectを選択するとリモートデスクトップのログイン画面が表示されるはずですが、、、
Untitled4.png

Unable to connectとなりました。
image.png

原因と解決

sshでインスタンスに接続し、xrdpのステータスを確認するとエラーが出ています。

[ec2-user@ip-xxx-xx-xx-xx ~]$ sudo systemctl status xrdp -l
● xrdp.service - xrdp daemon
   Loaded: loaded (/usr/lib/systemd/system/xrdp.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2024-07-04 14:37:47 UTC; 30min ago
     Docs: man:xrdp(8)
           man:xrdp.ini(5)
 Main PID: 3034 (xrdp)
   CGroup: /system.slice/xrdp.service
           └─3034 /usr/sbin/xrdp --nodaemon

Jul 04 14:50:27 ip-xxx-xx-xx-xx.ap-northeast-1.compute.internal xrdp[3232]: [INFO ] Using default X.509 certificate: /etc/xrdp/cert.pem
Jul 04 14:50:27 ip-xxx-xx-xx-xx.ap-northeast-1.compute.internal xrdp[3232]: [ERROR] Cannot read certificate file /etc/xrdp/cert.pem: No such file or directory
Jul 04 14:50:27 ip-xxx-xx-xx-xx.ap-northeast-1.compute.internal xrdp[3232]: [INFO ] Using default X.509 key file: /etc/xrdp/key.pem
Jul 04 14:50:27 ip-xxx-xx-xx-xx.ap-northeast-1.compute.internal xrdp[3232]: [ERROR] Cannot read private key file /etc/xrdp/key.pem: No such file or directory
Jul 04 14:50:27 ip-xxx-xx-xx-xx.ap-northeast-1.compute.internal xrdp[3232]: [WARN ] TLSv1.3 enabled by config, but not supported by system OpenSSL
Jul 04 14:50:27 ip-xxx-xx-xx-xx.ap-northeast-1.compute.internal xrdp[3232]: [ERROR] Cannot accept TLS connections because certificate or private key file is not readable. certificate file: [/etc/xrdp/cert.pem], private key file: [/etc/xrdp/key.pem]
Jul 04 14:50:27 ip-xxx-xx-xx-xx.ap-northeast-1.compute.internal xrdp[3232]: [INFO ] Security protocol: configured [], requested [SSL|HYBRID|HYBRID_EX|RDP], selected []
Jul 04 14:50:27 ip-xxx-xx-xx-xx.ap-northeast-1.compute.internal xrdp[3232]: [ERROR] xrdp_sec_incoming: xrdp_iso_incoming failed
Jul 04 14:50:27 ip-xxx-xx-xx-xx.ap-northeast-1.compute.internal xrdp[3232]: [ERROR] xrdp_rdp_incoming: xrdp_sec_incoming failed
Jul 04 14:50:27 ip-xxx-xx-xx-xx.ap-northeast-1.compute.internal xrdp[3232]: [ERROR] xrdp_process_main_loop: libxrdp_process_incoming failed

証明書の設定が原因だった模様。

公式の手順に従って証明書を導入して解決。なかなかこの記事に辿り着けなかったので苦労しました。(当該記事は日本語翻訳はされていません。)

足りなかった部分がこれ。

6. Install the certificate and key.
If you already have a certificate and key, copy them to the /etc/xrdp/ directory as follows:
Certificate — /etc/xrdp/cert.pem
Key — /etc/xrdp/key.pem
If you do not have a certificate and key, use the following command to generate them in the /etc/xrdp directory.

$ sudo openssl req -x509 -sha384 -newkey rsa:3072 -nodes -keyout >/etc/xrdp/key.pem -out /etc/xrdp/cert.pem -days 365

Note
This command generates a certificate that is valid for 365 days.

指示された通りに証明書を用意して接続したところ、無事接続できました。

0
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
0
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?