株式会社ヴァンデミックシステム

Blog

<スポンサーリンク>

Dockerfile

FROM centos:centos7

# OpenSSH サーバをインストールする
RUN yum -y install openssh-server

# root でログインできるようにする
RUN sed -ri 's/^#PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config

# root のパスワードを 設定
RUN echo 'root:a' | chpasswd

# 使わないにしてもここに公開鍵を登録しておかないとログインできない
RUN ssh-keygen -t rsa -N "" -f /etc/ssh/ssh_host_rsa_key

# sshd の使うポートを公開する
EXPOSE 22

# systemctlを使えるようにする
CMD ["/sbin/init"] 

ビルド

docker build -t centos7-ssh . 

起動

docker run --privileged -d -p 20022:22 -t centos7-ssh:latest

<スポンサーリンク>

コメントを残す

Allowed tags:  you may use these HTML tags and attributes: <a href="">, <strong>, <em>, <h1>, <h2>, <h3>
Please note:  all comments go through moderation.

*

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)