2026年8月24日月曜日

古い認証アルゴリズムの sshd を検証で起動する方法

古い認証アルゴリズムの sshd を検証で起動する方法

概要

検証用途で一時的に起動させる方法を紹介します

環境

  • Ubuntu 24.04
  • openssh-server 9.6p1

ホスト鍵作成

mkdir -p /tmp/sshd-legacy-test
if [ ! -f /tmp/sshd-legacy-test/ssh_host_rsa_key ]; then
ssh-keygen -q -t rsa -b 2048 -f /tmp/sshd-legacy-test/ssh_host_rsa_key -N ''
fi

設定ファイル作成

cat > /tmp/sshd-legacy-test/sshd_config <<'EOF'
Port 2222
ListenAddress 127.0.0.1
HostKey /tmp/sshd-legacy-test/ssh_host_rsa_key
PidFile /tmp/sshd-legacy-test/sshd.pid
LogLevel VERBOSE
UsePAM no
PasswordAuthentication no
KbdInteractiveAuthentication no
ChallengeResponseAuthentication no
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PermitRootLogin no
AllowUsers devops

X11Forwarding no
AllowTcpForwarding no
PrintMotd no
Subsystem sftp internal-sftp

KexAlgorithms +diffie-hellman-group14-sha1
HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa
EOF

設定ファイル確認

  • /usr/sbin/sshd -t -f /tmp/sshd-legacy-test/sshd_config

起動

  • /usr/sbin/sshd -D -e -f /tmp/sshd-legacy-test/sshd_config
  • ss -ltn | grep ':2222 '

停止

if [ -f /tmp/sshd-legacy-test/sshd.pid ]; then
kill "$(cat /tmp/sshd-legacy-test/sshd.pid)"
fi

0 件のコメント:

コメントを投稿