====== 80 レスキューモードでSSHD起動 ====== 1.CentOS6のISOで起動 ===== 2.SSHDの準備 ===== #sshd_configのコピー cp -p /etc/ssh/sshd_config.anaconda /etc/ssh/sshd_config #HOST RSA KEY・HOST DSA KEYの作成 /usr/bin/ssh-keygen -q -t rsa -f /etc/ssh/ssh_host_rsa_key -C '' -N '' /usr/bin/ssh-keygen -q -t dsa -f /etc/ssh/ssh_host_dsa_key -C '' -N '' chmod 600 /etc/ssh/ssh_host_* #sshd_configへ設定追加 echo "Protocol 2" >> /etc/ssh/sshd_config ===== 3.SSHを一度起動 ===== ※注意:この状態だと、どこからでもパスワードなしでログインできてしまう。 /sbin/sshd ===== 4. SSHログインして設定変更 ===== ssh root@[IP ADDRESS] mkdir /root/.ssh/ touch /root/.ssh/authorized_keys chmod -R 600 /root/.ssh/ #鍵作成・Authorized_keysに追加 ssh-keygen cat /root/.ssh/id_rsa.pub | tee > /root/.ssh/authorized_keys cat /root/.ssh/id_rsa # sshd_configを鍵認証のみに修正 sed -r -i -e '/PermitRootLogin.*/d' -e '/^PasswordAuthentication.*/d' /etc/ssh/sshd_config echo "PermitRootLogin without-password" >> /etc/ssh/sshd_config echo "PasswordAuthentication no" >> /etc/ssh/sshd_config ===== 5.SSD再起動 ===== ※この再起動後、作成した鍵のみでSSDログインできるようになります。 # SSHプロセスを再起動 ps auxw | grep sshd kill -s TERM [SSH PROCESS ID] # SSHの起動 /sbin/sshd {{tag>sshd rescue}}