このドキュメントでは、Nexusプラットフォームで暗号、MAC、およびKexアルゴリズムを追加(または)削除する手順について説明します。
LinuxとBashの基本を理解しておくことをお勧めします。
このドキュメントの情報は、次のハードウェアとソフトウェアのバージョンに基づいています。
このドキュメントの情報は、特定のラボ環境にあるデバイスに基づいて作成されたものです。このドキュメントで使用するすべてのデバイスは、クリアな(デフォルト)設定で作業を開始しています。本稼働中のネットワークでは、各コマンドによって起こる可能性がある影響を十分確認してください。
一部のセキュリティスキャンでは、Nexusデバイスで使用される脆弱な暗号化方式を検出できます。この場合、安全でないアルゴリズムを削除するには、スイッチ上のdcos_sshd_configファイルに対する変更が必要です。
プラットフォームが使用する暗号、MAC、およびKexアルゴリズムを確認するには、外部デバイスからこれを確認します。次のオプションを使用できます。
Nexusデバイスに到達できるPCでコマンドラインを開き、コマンドssh -vvv
C:\Users\xxxxx>ssh -vvv
--------- snipped ------------
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,curve25519-sha256@libssh.org <--- Kex algorithms
debug2: host key algorithms: ssh-rsa
debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,aes192-cbc,aes256-cbc
debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,aes192-cbc,aes256-cbc <--- encryption algorithms
debug2: MACs ctos: hmac-sha1
debug2: MACs stoc: hmac-sha1 <--- mac algorithms
debug2: compression ctos: none,zlib@openssh.com
debug2: compression stoc: none,zlib@openssh.com <--- compression algorithms
これは次の製品に適用されます。
1. bashシェル機能を有効にし、bashモードで次のコマンドを実行します。
switch(config)# feature bash-shell
switch(config)#
switch(config)# run bash
bash-4.3$
2. dcos_sshd_configファイルの内容を確認します。
bash-4.3$ cat /isan/etc/dcos_sshd_config
注:特定の行を確認するには、egrepを使用できます。cat /isan/etc/dcos_sshd_config | grep MAC
これは次の製品に適用されます。
手順:
1. TACケースを開き、スイッチで実行されているNXOSのバージョンと一致するdplugファイルを取得します。
2. dplugファイルをブートフラッシュにアップロードし、そのコピーを作成します。
switch# copy bootflash:nuova-or-dplug-mzg.7.3.8.N1.1 bootflash:dp
注:元のdplugファイルのコピー(「dp」)がブートフラッシュに作成されるため、コピーが削除されるのはdplugのロード後だけで、元のdplugファイルは以降の実行でブートフラッシュに残ります。
3. loadコマンドを実行して、dplugのコピーをロードします。
n5k-1# load bootflash:dp
Loading plugin version 7.3(8)N1(1)
###############################################################
Warning: debug-plugin is for engineering internal use only!
For security reason, plugin image has been deleted.
###############################################################
Successfully loaded debug-plugin!!!
Linux(debug)#
Linux(debug)#
2. dcos_sshd_configファイルを確認します。
Linux(debug)# cat /isan/etc/dcos_sshd_config
1. dcos_sshd_configファイルのコピーをbootflash:に送信します。
Linux(debug)# cd /isan/etc/
Linux(debug)# copy dcos_sshd_config /bootflash/dcos_sshd_config
Linux(debug)# exit
2. コピーがブートフラッシュにあることを確認します。
switch(config)# dir bootflash: | i ssh
7372 Mar 24 02:24:13 2023 dcos_sshd_config
3. サーバーにエクスポートする:
switch# copy bootflash: ftp:
Enter source filename: dcos_sshd_config
Enter vrf (If no input, current vrf 'default' is considered): management
Enter hostname for the ftp server: <hostname>
Enter username: <username>
Password:
***** Transfer of file Completed Successfully *****
Copy complete, now saving to disk (please wait)...
Copy complete.
4. ファイルに必要な変更を加え、ブートフラッシュにインポートして戻します。
1. 変更したdcos_sshd_configファイルをブートフラッシュにアップロードします。
switch# copy ftp: bootflash:
Enter source filename: dcos_sshd_config_modified.txt
Enter vrf (If no input, current vrf 'default' is considered): management
Enter hostname for the ftp server: <hostname>
Enter username: <username>
Password:
***** Transfer of file Completed Successfully *****
Copy complete, now saving to disk (please wait)...
Copy complete.
switch#
/isan/etc/にある既存のdcos_sshd_configファイルを、ブートフラッシュにある修正済みのdcos_sshd_configファイルに置き換えます。 このプロセスは、リブート後も保持されません
ssh configファイルをbootflash:にswitch# dir bootflash: | i ssh
7372 Mar 24 02:24:13 2023 dcos_sshd_config_modified
2. bashまたはLinux(debug)#モードで、既存のdcos_sshd_configファイルをbootflash:にあるファイルで上書きします。
bash-4.3$ sudo su
bash-4.3# copy /bootflash/dcos_sshd_config_modified /isan/etc/dcos_sshd_config
3. 変更が正常に行われたことを確認します。
bash-4.3$ cat /isan/etc/dcos_sshd_config
EEMスクリプトを使用すると、リロード後にログ「VDC_MGR-2-VDC_ONLINE」が更新されたときにトリガーされます。EEMがトリガーされると、pyスクリプトが実行され、/isan/etc/にある既存のdcos_sshd_configファイルが、ブートフラッシュ内にある修正されたdcos_sshd_configファイルに置き換えられます。 これは、「機能bash-shell」をサポートするNX-OSバージョンにのみ適用されます。
switch# dir bootflash: | i ssh
7404 Mar 03 16:10:43 2023 dcos_sshd_config_modified_7k
switch#
2. dcos_sshd_configファイルに変更を適用するpyスクリプトを作成します。ファイルは「py」拡張子を付けて保存してください。
#!/usr/bin/env python
import os
os.system("sudo usermod -s /bin/bash root")
os.system("sudo su -c \"cp /bootflash/dcos_sshd_config_modified_7k /isan/etc/dcos_sshd_config\"")
3. Pythonスクリプトをブートフラッシュにアップロードします。
switch# dir bootflash:///scripts
175 Mar 03 16:11:01 2023 ssh_workaround_7k.py
注:Pythonスクリプトはすべてのプラットフォームでほぼ同じですが、N7KにはCisco Bug ID CSCva14865を解決するためのいくつかの追加行が含まれることが異なります。
4. スクリプトとブートフラッシュ(ステップ1で説明)のdcos_sshd_configファイル名が同じであることを確認します。
switch# dir bootflash: | i ssh
7404 Mar 03 16:10:43 2023 dcos_sshd_config_modified_7k
switch#
switch# show file bootflash:///scripts/ssh_workaround_7k.py
#!/usr/bin/env python
import os
os.system("sudo usermod -s /bin/bash root")
os.system("sudo su -c \"cp /bootflash/dcos_sshd_config_modified_7k /isan/etc/dcos_sshd_config\"")
switch#
5. スクリプトを1回実行すると、dcos_sshd_configファイルが変更されます。
switch# source ssh_workaround_7k.py
switch#
6. EEMスクリプトを設定します。スイッチがリブートされるたびにpyスクリプトが実行されると、再び起動します。
EEM N7K:
event manager applet SSH_workaround
event syslog pattern "vdc 1 has come online"
action 1.0 cli command "source ssh_workaround_7k.py"
action 2 syslog priority alerts msg "SSH Workaround implemented"
注:EEM構文はNXOSのリリースによって異なる場合があります(バージョンによっては「action cli」が必要な場合と、他のバージョンでは「action cli command」が必要な場合があります)。EEMコマンドが正確であることを確認してください。
switch# dir | i i ssh
7732 Jun 18 16:49:47 2024 dcos_sshd_config
7714 Jun 18 16:54:20 2024 dcos_sshd_config_modified
switch#
2. dcos_sshd_configファイルに変更を適用するpyスクリプトを作成します。ファイルは「py」拡張子を付けて保存してください。
#!/usr/bin/env python
import os
os.system("sudo su -c \"cp /bootflash/dcos_sshd_config_modified /isan/etc/dcos_sshd_config\"")
3. Pythonスクリプトをブートフラッシュにアップロードします。
switch# dir | i i .py
127 Jun 18 17:21:39 2024 ssh_workaround_9k.py
switch#
4. スクリプト(ステップ1)とブートフラッシュ(ステップ1)で確認したdcos_sshd_configファイル名が同じであることを確認します。
switch# dir | i i ssh
7732 Jun 18 16:49:47 2024 dcos_sshd_config
7714 Jun 18 16:54:20 2024 dcos_sshd_config_modified
127 Jun 18 17:21:39 2024 ssh_workaround_9k.py
switch#
switch# sh file bootflash:ssh_workaround_9k.py
#!/usr/bin/env python
import os
os.system("sudo su -c \"cp /bootflash/dcos_sshd_config_modified /isan/etc/dcos_sshd_config\"")
switch#
5. スクリプトを1回実行すると、dcos_sshd_configファイルが変更されます。
switch# python bootflash:ssh_workaround_9k.py
6. EEMスクリプトを設定します。pyスクリプトが毎回実行されると、スイッチがリブートされて再び起動します。
EEM N9KおよびN3K:
event manager applet SSH_workaround
event syslog pattern "vdc 1 has come online"
action 1.0 cli python bootflash:ssh_workaround_9k.py
action 2 syslog priority alerts msg SSH Workaround implemented
注:EEM構文はNXOSのリリースによって異なる場合があります(バージョンによっては「action cli」が必要な場合と、他のバージョンでは「action cli command」が必要な場合があります)。EEMコマンドが正確であることを確認してください。
修正されたdplugファイルは、Cisco Bug ID CSCvr23488で次のKexアルゴリズムを削除するために作成されました。
Cisco Bug ID CSCvr23488によって提供されるdpugファイルは、Linuxシェルへのアクセスに使用されるファイルと同じではありません。TACケースをオープンし、修正されたdplugをCisco Bug ID CSCvr23488から取得します。
C:\Users\user>ssh -vvv admin@
---- snipped ----
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1, diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 <--- kex algorithms
debug2: host key algorithms: ssh-rsa
debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr
debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr <--- encryption algorithms
debug2: MACs ctos: hmac-sha1
debug2: MACs stoc: hmac-sha1 <--- mac algorithms
debug2: compression ctos: none,zlib@openssh.com
debug2: compression stoc: none,zlib@openssh.com <--- compression algorithms
2. 変更したdplugファイルのコピーを作成します。
switch# copy bootflash:nuova-or-dplug-mzg.7.3.14.N1.1_CSCvr23488.bin bootflash:dp
注:元のdplugファイルのコピー(「dp」)がブートフラッシュで作成されます。コピーが削除されるのは、dplugがロードされた後だけです。元のdplugファイルは、以降の実行でブートフラッシュに残ります。
3. Cisco Bug ID CSCvr23488のdplugファイルを手動で適用します。
switch# load bootflash:dp2
Loading plugin version 7.3(14)N1(1)
###############################################################
Warning: debug-plugin is for engineering internal use only!
For security reason, plugin image has been deleted.
###############################################################
Successfully loaded debug-plugin!!!
Workaround for CSCvr23488 implemented
switch#
4. 新しいdcos_sshd_config設定を確認します。
C:\Users\user>ssh -vvv admin@<hostname>
---- snipped ----
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: diffie-hellman-group14-sha1,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521
debug2: host key algorithms: ssh-rsa
debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr
debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr
debug2: MACs ctos: hmac-sha1
debug2: MACs stoc: hmac-sha1
debug2: compression ctos: none,zlib@openssh.com
debug2: compression stoc: none,zlib@openssh.com
5. EEMスクリプトを使用して、この変更がリブート後も保持されることを確認します。
event manager applet CSCvr23488_workaround
event syslog pattern "VDC_MGR-2-VDC_ONLINE"
action 1 cli command "copy bootflash:nuova-or-dplug-mzg.7.3.14.N1.1_CSCvr23488.bin bootflash:dp"
action 2 cli command "load bootflash:dp"
action 3 cli command "conf t ; no feature ssh ;feature ssh"
action 4 syslog priority alerts msg "CSCvr23488 Workaround implemented"
注:修正したdplugを適用した後、このプラットフォームでSSH機能をリセットする必要があります。dplugファイルがブートフラッシュに存在し、EEMが適切なdplugファイル名で設定されている必要があります。dplugファイル名は、スイッチのバージョンによって異なる場合があります。必要に応じてスクリプトを変更してください。アクション1は、ブートフラッシュ内の元のdplugファイルのコピーを「dp」と呼ばれる別のファイルに作成します。そのため、元のdplugファイルはロード後に削除されません。
F241.06.24-N7706-1(config)# feature bash-shell
F241.06.24-N7706-1(config)# run bash
bash-4.3$ sudo su
Cannot execute /isanboot/bin/nobash: No such file or directory <---
bash-4.3$
これを解決するには、次のコマンドを実行します。
bash-4.3$ sudo usermod -s /bin/bash root
上記のコマンドを実行すると、「sudo su」が機能します。
bash-4.3$ sudo su
bash-4.3#
注:この変更はリロード後も有効です。
VDCごとに個別のdcos_sshd_configファイルがあります。異なるVDCでSSHパラメータを変更する必要がある場合は、対応するdcos_sshd_configファイルを変更してください。
N7K# run bash
bash-4.3$ cd /isan/etc/
bash-4.3$ ls -la | grep ssh
-rw-rw-r-- 1 root root 7564 Mar 27 13:48 dcos_sshd_config <--- VDC 1
-rw-rw-r-- 1 root root 7555 Mar 27 13:48 dcos_sshd_config.2 <--- VDC 2
-rw-rw-r-- 1 root root 7555 Mar 27 13:48 dcos_sshd_config.3 <--- VDC 3
10.5(1)を実行するスイッチからのCLIの例:
switch(config)# ssh ?
cipher-mode Set Cipher-mode for ssh
ciphers Ciphers to encrypt the connection <<<<<<<<<
idle-timeout SSH Client session idle timeout value
kexalgos Key exchange methods that are used to generate per-connection keys <<<<<<<<<
key Generate SSH Key
keytypes Public key algorithms that the server can use to authenticate itself to the client
login-attempts Set maximum login attempts from ssh
login-gracetime Set login gracetime for ssh connection
macs Message authentication codes used to detect traffic modification <<<<<<<<<
port Set port number for ssh
rekey Renegotiate ssh key
switch(config)# ssh ciphers ?
WORD Algorithm name to be configured (Max Size 128)
aes256-gcm <Deprecated> enable aes256-gcm
all Control known weak SSH algorithms in current version of NX-OS in addition to the base set of strong algorithms
switch(config)# ssh macs ?
WORD Algorithm name to be configured (Max Size 128)
all Control known weak SSH algorithms in current version of NX-OS in addition to the base set of strong algorithms
switch(config)# ssh kexalgos ?
WORD Algorithm name to be configured (Max Size 128)
all Control known weak SSH algorithms in current version of NX-OS in addition to the base set of strong algorithms
以前のコードを実行しているプラットフォームでは、暗号、MAC、およびKexAlgorithmsを追加できます。これらのバージョンには、特定のアルゴリズムを個別に選択するオプションはありません。「all」オプションだけがサポートされています。
N9000(config)# ssh macs ?
all Enable algorithms supported in current version of SSH
N9000(config)# ssh kexalgos ?
all Enable algorithms supported in current version of SSH
ecdh-sha2-nistp384 Enable ecdh-sha2-nistp384
N9000(config)# ssh ciphers ?
aes256-gcm Enable aes256-gcm
all Enable algorithms supported in current version of SSH
注:これらのコマンドは、リリース8.3(1)以降のNexus 7000で使用できます。Nexus 3000/9000プラットフォームでは、リリース7.0(3)I7(8)以降でコマンドが使用可能になります。(すべての9.3(x)リリースにこのコマンドがあります。『Cisco Nexus 9000 Series NX-OS Security Configuration Guide, Release 9.3(x)』を参照してください。
| 改定 | 発行日 | コメント |
|---|---|---|
2.0 |
31-Jul-2026
|
スペル、文法、タイトル、区切りセクションへの水平線の挿入、読みやすさの改善、CCWアラートの修正。 |
1.0 |
01-Jul-2024
|
初版 |