In dit document worden de stappen beschreven die moeten worden uitgevoerd om coderingen, MAC's en Kex-algoritmen in Nexus-platforms toe te voegen (of te verwijderen).
Cisco raadt u aan de basisprincipes van Linux en Bash te begrijpen.
De informatie in dit document is gebaseerd op de volgende hardware- en softwareversies:
De informatie in dit document is gebaseerd op de apparaten in een specifieke laboratoriumomgeving. Alle apparaten die in dit document worden beschreven, hadden een opgeschoonde (standaard)configuratie. Als uw netwerk live is, moet u zorgen dat u de potentiële impact van elke opdracht begrijpt.
Sommige beveiligingsscans kunnen zwakke coderingsmethoden vinden die worden gebruikt door Nexus-apparaten. Als dit gebeurt, zijn wijzigingen in het dcos_sshd_config-bestand op switches vereist om onveilige algoritmen te verwijderen.
Om te bevestigen welke Ciphers, MAC's en Kex-algoritmen een platform gebruikt, controleert u dit vanaf een extern apparaat. U kunt deze opties gebruiken:
Open een CMD-lijn op een pc die het Nexus-apparaat kan bereiken en voer de opdracht ssh -vvv uit
C:\Users\xxxxx>ssh -vvv <hostname>
--------- 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
Dit geldt voor:
1. Schakel de bash-shell-functie in en in bash-modus:
switch(config)# feature bash-shell
switch(config)#
switch(config)# run bash
bash-4.3$
2. Controleer de inhoud van het bestand dcos_sshd_config:
bash-4.3$ cat /isan/etc/dcos_sshd_config
Opmerking: u kunt egrep gebruiken om naar specifieke regels te kijken: cat /isan/etc/dcos_sshd_config | grep MAC
Dit geldt voor:
Stappen:
1. Open een TAC-geval om het dplug-bestand te verkrijgen dat overeenkomt met de NXOS-versie die op de switch wordt uitgevoerd.
2. Upload het dplug-bestand naar bootflash en maak er een kopie van.
switch# copy bootflash:nuova-or-dplug-mzg.7.3.8.N1.1 bootflash:dp
Opmerking: Een kopie ("dp") van het oorspronkelijke dplug-bestand wordt gemaakt in bootflash, dus alleen de kopie wordt verwijderd nadat de dplug is geladen en het oorspronkelijke dplug-bestand blijft in bootflash voor volgende runs.
3. Laad de kopie van de dplug door de opdracht laden uit te voeren.
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. Controleer het bestand dcos_sshd_config.
Linux(debug)# cat /isan/etc/dcos_sshd_config
1. Stuur een kopie van het dcos_sshd_config-bestand naar bootflash:
Linux(debug)# cd /isan/etc/
Linux(debug)# copy dcos_sshd_config /bootflash/dcos_sshd_config
Linux(debug)# exit
2. Bevestig dat de kopie zich op bootflash bevindt:
switch(config)# dir bootflash: | i ssh
7372 Mar 24 02:24:13 2023 dcos_sshd_config
3. Exporteren naar een server:
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. Vul alle noodzakelijke wijzigingen in het bestand in en importeer terug naar bootflash.
1. Upload het gewijzigde dcos_sshd_config-bestand naar Boot Flash.
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#
Door het bestaande dcos_sshd_config-bestand onder /isan/etc/ te vervangen door een aangepast dcos_sshd_config-bestand in bootflash. Dit proces is niet persistent bij reboots
ssh config bestand naar bootflash:switch# dir bootflash: | i ssh
7372 Mar 24 02:24:13 2023 dcos_sshd_config_modified
2. In de modus bash of Linux (debug)# overschrijft u het bestaande dcos_sshd_config-bestand met het bestand in bootflash:
bash-4.3$ sudo su
bash-4.3# copy /bootflash/dcos_sshd_config_modified /isan/etc/dcos_sshd_config
3. Bevestig dat de wijzigingen succesvol waren:
bash-4.3$ cat /isan/etc/dcos_sshd_config
Door een EEM-script te gebruiken, wordt dit geactiveerd wanneer het log "VDC_MGR-2-VDC_ONLINE" na een herladen wordt vernieuwd. Als de EEM wordt geactiveerd, wordt een py-script uitgevoerd en vervangt het bestaande dcos_sshd_config-bestand onder /isan/etc/ door een gewijzigd dcos_sshd_config-bestand in bootflash. Dit geldt alleen voor NX-OS-versies die "feature bash-shell" ondersteunen.
switch# dir bootflash: | i ssh
7404 Mar 03 16:10:43 2023 dcos_sshd_config_modified_7k
switch#
2. Maak een py-script dat wijzigingen toepast op het bestand dcos_sshd_config. Zorg ervoor dat u het bestand opslaat met de extensie "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. Upload het Python-script naar bootflash.
switch# dir bootflash:///scripts
175 Mar 03 16:11:01 2023 ssh_workaround_7k.py
Opmerking: Python-scripts zijn vrijwel hetzelfde op alle platforms, behalve N7K, dat enkele extra regels bevat om Cisco-bug-ID CSCva14865 te overwinnen.
4. Zorg ervoor dat de bestandsnaam dcos_sshd_config van het script en bootflash (in stap 1.) hetzelfde zijn:
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. Voer het script eenmaal uit, dus het dcos_sshd_config-bestand wordt gewijzigd.
switch# source ssh_workaround_7k.py
switch#
6. Configureer een EEM-script, zodra het py-script wordt uitgevoerd elke keer dat de switch opnieuw wordt opgestart, komt het terug naar boven.
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"
Opmerking: EEM-syntaxis kan variëren op verschillende NXOS-releases (sommige versies vereisen "action cli" en andere "action cli command"), om ervoor te zorgen dat de EEM-opdrachten nauwkeurig zijn.
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. Maak een py-script dat wijzigingen toepast op het bestand dcos_sshd_config. Zorg ervoor dat u het bestand opslaat met de extensie "py".
#!/usr/bin/env python
import os
os.system("sudo su -c \"cp /bootflash/dcos_sshd_config_modified /isan/etc/dcos_sshd_config\"")
3. Upload het python script naar bootflash.
switch# dir | i i .py
127 Jun 18 17:21:39 2024 ssh_workaround_9k.py
switch#
4. Zorg ervoor dat de bestandsnaam dcos_sshd_config van het script en bootflash (Stap 1.) hetzelfde zijn:
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. Voer het script eenmaal uit, zodat het dcos_sshd_config-bestand wordt gewijzigd.
switch# python bootflash:ssh_workaround_9k.py
6. Configureer een EEM-script, zodra het py-script elke keer wordt uitgevoerd, wordt de switch opnieuw opgestart en komt deze terug naar boven.
EEM N9K en 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
Opmerking: EEM-syntaxis kan variëren op verschillende NXOS-releases (sommige versies vereisen "action cli" en andere "action cli command"), om ervoor te zorgen dat de EEM-opdrachten nauwkeurig zijn.
Een gewijzigd dplug-bestand is gemaakt via Cisco bug ID CSCvr23488 om deze Kex-algoritmen te verwijderen:
De dpug bestanden die via Cisco bug ID CSCvr23488 zijn geleverd zijn niet dezelfde als die worden gebruikt om toegang te krijgen tot de Linux Shell. Open een TAC-geval om de gewijzigde dplug van Cisco bug ID CSCvr23488 te verkrijgen.
C:\Users\user>ssh -vvv admin@<hostname>
---- 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. Maak een kopie van het gewijzigde dplug-bestand.
switch# copy bootflash:nuova-or-dplug-mzg.7.3.14.N1.1_CSCvr23488.bin bootflash:dp
Opmerking: Een kopie ("dp") van het oorspronkelijke dplug-bestand wordt gemaakt in bootflash, alleen de kopie wordt verwijderd nadat de dplug is geladen en het oorspronkelijke dplug-bestand blijft in bootflash voor volgende runs.
3. Pas het dplug-bestand van Cisco bug ID CSCvr23488 handmatig toe:
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. Controleer de nieuwe dcos_sshd_config-instellingen:
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. Zorg ervoor dat deze wijziging aanhoudt bij het opnieuw opstarten met een EEM-script:
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"
Opmerking: nadat de gewijzigde dplug is toegepast, moet de SSH-functie op dit platform worden gereset. Het dplug-bestand moet aanwezig zijn in bootflash en de EEM moet worden geconfigureerd met de juiste dplug-bestandsnaam. De dplug-bestandsnaam kan variëren afhankelijk van de versie van de switch, zorg ervoor dat u het script naar behoefte aanpast. Actie 1 maakt een kopie van het oorspronkelijke dplug-bestand in bootflash naar een ander bestand met de naam "dp", zodat het oorspronkelijke dplug-bestand niet wordt verwijderd zodra het is geladen.
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$
Om dit te overwinnen, loop:
bash-4.3$ sudo usermod -s /bin/bash root
Nadat u de opdracht prior hebt uitgevoerd, werkt "sudo su":
bash-4.3$ sudo su
bash-4.3#
Opmerking: deze wijziging overleeft een herbelasting niet.
Er is een afzonderlijk dcos_sshd_config-bestand voor elke VDC, als SSH-parameters moeten worden gewijzigd op een andere VDC, zorg er dan voor dat u het overeenkomstige dcos_sshd_config-bestand wijzigt.
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
Voorbeeld CLI van een switch met 10.5(1):
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
Voor platforms met eerdere code kunt u ciphers, MAC's en KexAlgorithms toevoegen. Deze versies bieden niet de mogelijkheid om specifieke algoritmen afzonderlijk te selecteren; alleen de optie 'alles' wordt ondersteund.
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
Opmerking: Deze opdrachten zijn beschikbaar op de Nexus 7000 met releases 8.3(1) en hoger. Voor het Nexus 3000/9000-platform wordt de opdracht beschikbaar met versie 7.0(3)I7(8) en hoger. (Alle 9.3(x) releases hebben dit commando ook. Zie Cisco Nexus 9000 Series NX-OS Security Configuration Guide, versie 9.3(x)).
| Revisie | Publicatiedatum | Opmerkingen |
|---|---|---|
2.0 |
31-Jul-2026
|
Bijgewerkte spelling, grammatica, titel, ingevoegde horizontale regels om secties/leesbaarheid te scheiden, vaste CCW-waarschuwingen. |
1.0 |
01-Jul-2024
|
Eerste vrijgave |