2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[AIX] OpenSSH の config で「+ -」両方を設定したいときの対応

Last updated at Posted at 2025-12-02

はじめに

AIX の OpenSSH の sshd_config で KexAlgorithms について「+ -」両方を設定したいときにテストしてみた結果をここにまとめてみます。

お急ぎの方向け : 結論

「+ -」の同時指定はできなさそうなので、稼働する OpenSSH のデフォルト値を踏まえて全指定する。

前提

動作環境(試した環境)

  • AIX (7300-03-01-2520)
# oslevel -s
7300-03-01-2520
#
# ssh -V
OpenSSH_9.7p1, OpenSSL 3.0.15 3 Sep 2024
#

変更内容

KexAlgorithms に以下の要件が発生

  • "長生き" なサーバーとの SSH 要件で diffie-hellman-group1-sha1 を追加したい(+ の要件)
  • OpenSSH 9.0 以降でデフォルト有効になった sntrup761x25519-sha512@ openssh .com を外したい(- の要件)
    • リンク表示を避けるため、意図的に @ と open.. の間に半角スペースを挟んで記載します

sntrup761x25519-sha512@ openssh.com については以下で公開されています。必要に応じて設定を検討ください。

【TF】【IBMPower】【Information】OpenSSH v9 に更新時の注意点
https://www.ibm.com/support/pages/node/7185201

テストしてみた内容

念のため、sshd_config の設定内容は一部省略とさせていただきます。

sshd_config の修正内容が OpenSSH に理解されない記載の場合、エラーになります。エラー状態を気づかずに sshd プロセスを停止・起動すると sshd プロセスは起動しません。

sshd_config の修正後は sshd -T で確認することをつよくつよくおすすめいたします!

修正前に cp コマンドでファイルのバックアップを取っておくこともおすすめいたします!


0. 修正前

sshd_config の修正前の状態は以下でした。

# grep -i KexAlgorithms /etc/ssh/sshd_config
#
# sshd -T >/dev/null ; echo $?
0
#
# sshd -T | grep -i ^KexAlgorithms | tr ' ' '\n' | tr ',' '\n' | grep -E "sntrup761x25519-sha512@openssh.com|diffie-hellman-group1-sha1"
sntrup761x25519-sha512@openssh.com
#

1. 1 つずつの指定

1 つずつの設定は問題なくできます。

1-a) diffie-hellman-group1-sha1 の追加

# grep -i KexAlgorithms /etc/ssh/sshd_config
KexAlgorithms +diffie-hellman-group1-sha1
#
# sshd -T >/dev/null ; echo $?
0
# sshd -T | grep -i ^KexAlgorithms | tr ' ' '\n' | tr ',' '\n' | grep -E "sntrup761x25519-sha512@openssh.com|diffie-hellman-group1-sha1"
sntrup761x25519-sha512@openssh.com
diffie-hellman-group1-sha1
#

1-b) sntrup761x25519-sha512@ openssh.com の削除

# grep -i KexAlgorithms /etc/ssh/sshd_config
KexAlgorithms -sntrup761x25519-sha512@openssh.com
#
# sshd -T >/dev/null ; echo $?
0
#
# sshd -T | grep -i ^KexAlgorithms | tr ' ' '\n' | tr ',' '\n' | grep -E "sntrup761x25519-sha512@openssh.com|diffie-hellman-group1-sha1"
#

2. 2 つをスペース区切りで設定

複数指定方法が分からず、試しにスペース区切りにしてみました。
結果としては構文を理解されずにエラーになります。

# grep -i KexAlgorithms /etc/ssh/sshd_config
KexAlgorithms +diffie-hellman-group1 -sha1 -sntrup761x25519-sha512@openssh.com
#
# sshd -T >/dev/null ; echo $?
Unsupported KEX algorithm "diffie-hellman-group1"
/etc/ssh/sshd_config line 121: Bad SSH2 KexAlgorithms '+diffie-hellman-group1'.
255
#

3. 2 つをカンマ区切りで設定

次に試したのがカンマ区切りです。
一方はエラー、他方はエラーにならないけど「+ -」両方を満たさないために NG という結果になりました。

3-a) + を先に - を後に指定

エラーになりました。

# grep -i KexAlgorithms /etc/ssh/sshd_config
KexAlgorithms +diffie-hellman-group1-sha1,-sntrup761x25519-sha512@openssh.com
#
# sshd -T >/dev/null ; echo $?
Unsupported KEX algorithm "-sntrup761x25519-sha512@openssh.com"
/etc/ssh/sshd_config line 121: Bad SSH2 KexAlgorithms '+diffie-hellman-group1-sha1,-sntrup761x25519-sha512@openssh.com'.
255
#

3-b) - を先に + を後に指定

エラーにならないが、追加したはずの diffie-hellman-group1-sha1 が有効になっておらず、期待した結果ではない…

# grep -i KexAlgorithms /etc/ssh/sshd_config
KexAlgorithms -sntrup761x25519-sha512@openssh.com,+diffie-hellman-group1-sha1
#
# sshd -T >/dev/null ; echo $?
0
#
# sshd -T | grep -i ^KexAlgorithms | tr ' ' '\n' | tr ',' '\n' | grep -E "sntrup761x25519-sha512@openssh.com|diffie-hellman-group1-sha1"
#

4. 「+ -」指定をやめて固定で指定する 【期待した結果になった】

「1-a) diffie-hellman-group1-sha1 の追加」で表示された内容から、手動で「sntrup761x25519-sha512@ openssh.com」を取り除いたものをそのまま指定しました。
期待した結果になりました!

※コメント行は将来の誰かが何を設定したのか分かるように残しています
※このあと、sshd プロセスの停止・起動 (stopsrc -s sshd / startsrc -s sshd を行いました)

# grep -i KexAlgorithms /etc/ssh/sshd_config
## KexAlgorithms : [sshd default] + diffie-hellman-group1-sha1 - sntrup761x25519-sha512@openssh.com
KexAlgorithms [内容を省略],diffie-hellman-group1-sha1
#
# sshd -T >/dev/null ; echo $?
0
#
# sshd -T | grep -i ^KexAlgorithms | tr ' ' '\n' | tr ',' '\n' | grep -E "sntrup761x25519-sha512@openssh.com|diffie-hellman-group1-sha1"
diffie-hellman-group1-sha1
#

記載を省略しましたが ssh_config も同様に KexAlgorithms に「diffie-hellman-group1-sha1 の追加 & sntrup761x25519-sha512@ openssh.com を外す」を試しましたが sshd_config と同じ動きでした。

おわりに

インターネット上で情報が見つからなければ試してみるっきゃない、ということで試しました。

最後までお読みいただき、ありがとうございます。
この記事がどなたかの一助になれますように!

参考

以上です!

2
0
4

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
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?