[AWS] AMI 作る前にやっておきたいこと


#!/bin/sh
rm -rf /tmp/*
rm -f /etc/ssh/ssh_host_*
if [ -d /var/log ]; then
find /var/log -type f -print | xargs -L1 /bin/cp /dev/null
fi
if [ -d /var/spool/mail ]; then
find /var/spool/mail -type f -print | xargs -L1 /bin/cp /dev/null
fi
/bin/cp /dev/null /root/.ssh/authorized_keys
/bin/cp /dev/null /root/.bash_history
if [ -f /root/.mysql_history ]; then
/bin/cp /dev/null /root/.mysql_history
fi
if [ -d /home/ec2-user ]; then
/bin/cp /dev/null /home/ec2-user/.ssh/authorized_keys
/bin/cp /dev/null /home/ec2-user/.bash_history
if [ -f /home/ec2-user/.mysql_history ]; then
/bin/cp /dev/null /home/ec2-user/.mysql_history
fi
fi
history -c
echo "clear!"

view raw

clear.sh

hosted with ❤ by GitHub

  • /var/log 以下のファイルを /dev/null で上書き
  • /var/spool/mail 以下のファイルを(略)
  • /root 以下の .ssh/authorized_keys, .bash_history, .mysql_history を(略)
  • (あれば) /home/ec2-user 以下の .ssh/authorized_keys, .bash_history, .mysql_history を(略)
  • /tmp/*, /etc/ssh/ssh_host_* を削除

をやるので、最低限必要なことはこれで足りるはず
参考: cloudpackブログ: 公開AMIを作成する直前で行っていること

せっかちなあなたには

# curl -L clear.ninjax.cc | bash; history -c 

authorized_keys 消すから、この作業やったら、そのインスタンスにはログインできなくなるよ


Posted

in

by

Tags:

Comments

コメントを残す

以下に詳細を記入するか、アイコンをクリックしてログインしてください。

WordPress.com ロゴ

WordPress.com アカウントを使ってコメントしています。 ログアウト /  変更 )

Facebook の写真

Facebook アカウントを使ってコメントしています。 ログアウト /  変更 )

%s と連携中

%d人のブロガーが「いいね」をつけました。