LoginSignup
9
9

More than 5 years have passed since last update.

CentOS6でsshサーバのみ動作させるdockfile

Posted at

以下のようにすればsshサーバ構築できた。
rootのパスワードは念のためすぐに変更。
authorized_keysは各自生成しておくこと。

FROM centos:centos6

MAINTAINER shotsky

# Install Packages
RUN yum update -y
RUN yum install -y passwd openssh openssh-server openssh-clients sudo

# Setup SSH 
RUN mkdir /root/.ssh
RUN chmod 700 /root/.ssh
ADD authorized_keys /root/.ssh/authorized_keys
RUN chmod 600 /root/.ssh/authorized_keys

RUN echo "root:root" | chpasswd

# Mod sshd_config
RUN sed -i 's/#PermitRootLogin yes/PermitRootLogin yes/g' /etc/ssh/sshd_config
RUN sed -i 's/^UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
RUN sed -i 's/^PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config
RUN sed -i 's/^#RSAAuthentication yes/RSAAuthentication yes/g' /etc/ssh/sshd_config
RUN sed -i 's/^#PubkeyAuthentication yes/PubkeyAuthentication yes/g' /etc/ssh/sshd_config

# Create host rsa&dsa keys
RUN service sshd start
RUN service sshd stop

CMD /usr/sbin/sshd -D
9
9
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
9
9