Windows の Docker Ubuntu に SSH で接続する

🔴 Dockerfile
FROM ubuntu

USER root

# sshサーバをインストール
RUN apt-get update && apt-get install -y openssh-server

# sshd用
RUN mkdir /var/run/sshd

# rootのパスワード
RUN echo 'root:pass' | chpasswd

# sshのrootでのアクセスを許可
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config

EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]

docker build -t default_repo:default_tag .

ssh root@localhost -p 22

参考 1
参考 2

以下が出たら対象の記述を削除して再実行( 登録される )

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ED25519 key sent by the remote host is
SHA256:XBwm/W+C5V4fTIce7Pmo4GaX7Wnut+FkkQM7Bj4WWEc.
Please contact your system administrator.
Add correct host key in C:\\Users\\lightbox/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in C:\\Users\\lightbox/.ssh/known_hosts:6
Host key for localhost has changed and you have requested strict checking.
Host key verification failed.

Notion まとめリンク

Docker, 記録