ガイド

10分で新しいVPSを保護する

初心者10分で読めます更新日 2026年6月18日
短い回答

5つの変更で、新しいサーバーに対するほぼすべての自動攻撃を排除できます:パスワード無効の鍵ベースSSH、root直接ログイン無効、IPv4とIPv6の両方をカバーするデフォルト拒否ファイアウォール、自動セキュリティ更新、fail2ban。これらは合わせておよそ10分かかり、どのプロバイダー機能よりも重要です。

01 SSHキーを生成してインストールする

Do this from your own machine, not the server. Ed25519 keys are shorter and faster than RSA and are supported everywhere that matters.

ssh-keygen -t ed25519 -C "onionvps-$(date +%Y%m)"
ssh-copy-id -i ~/.ssh/id_ed25519.pub root@YOUR_SERVER_IP

02 非rootユーザーを作成する

Working as root all the time removes a useful safety net and makes every mistake maximally expensive.

adduser --gecos "" ops
usermod -aG sudo ops
rsync --archive --chown=ops:ops ~/.ssh /home/ops

03 SSHデーモンを強化する

Disable password authentication entirely — brute force against key-only SSH is not possible. Keep a second terminal connected while you do this, so a mistake does not lock you out.

cat >/etc/ssh/sshd_config.d/99-hardening.conf <<'EOF'
PasswordAuthentication no
PermitRootLogin no
KbdInteractiveAuthentication no
AllowUsers ops
EOF
sshd -t && systemctl reload ssh

04 デフォルト拒否ファイアウォールを設定する

Cover IPv6 as well as IPv4. Every OnionVPS instance has a routed /64, so a v4-only ruleset leaves every service publicly reachable over v6.

ufw default deny incoming
ufw default allow outgoing
ufw allow 22/tcp
ufw allow 80,443/tcp
ufw enable
ufw status verbose   # confirm IPv6 shows as enabled

05 自動セキュリティ更新を有効にする

Unattended upgrades close the window between a patch being published and you noticing it exists.

apt install -y unattended-upgrades
dpkg-reconfigure -plow unattended-upgrades

06 fail2banをインストールしてスナップショットを取る

fail2ban mostly reduces log noise once passwords are disabled, but it is cheap. Then snapshot the configured state — that becomes your known-good baseline.

apt install -y fail2ban && systemctl enable --now fail2ban

よくある質問

SSHポートを変更すべきですか?

これはセキュリティというよりノイズ低減ですが、効果的なノイズ低減です — スキャナーの大部分はポート22のみを試します。鍵のみの認証と組み合わせると、残存リスクはどちらにしても無視できます。

ロックアウトされたらどうしますか?

コントロールパネルのアウトオブバンドVNCコンソールを使用します。これは仮想シリアルコンソールに接続され、ネットワークがまったくなくても動作します。