De documentatie van dit product is waar mogelijk geschreven met inclusief taalgebruik. Inclusief taalgebruik wordt in deze documentatie gedefinieerd als taal die geen discriminatie op basis van leeftijd, handicap, gender, etniciteit, seksuele oriëntatie, sociaaleconomische status of combinaties hiervan weerspiegelt. In deze documentatie kunnen uitzonderingen voorkomen vanwege bewoordingen die in de gebruikersinterfaces van de productsoftware zijn gecodeerd, die op het taalgebruik in de RFP-documentatie zijn gebaseerd of die worden gebruikt in een product van een externe partij waarnaar wordt verwezen. Lees meer over hoe Cisco gebruikmaakt van inclusief taalgebruik.
Cisco heeft dit document vertaald via een combinatie van machine- en menselijke technologie om onze gebruikers wereldwijd ondersteuningscontent te bieden in hun eigen taal. Houd er rekening mee dat zelfs de beste machinevertaling niet net zo nauwkeurig is als die van een professionele vertaler. Cisco Systems, Inc. is niet aansprakelijk voor de nauwkeurigheid van deze vertalingen en raadt aan altijd het oorspronkelijke Engelstalige document (link) te raadplegen.
Dit document beschrijft de stappen voor het toevoegen (of verwijderen) van Ciphers, MAC's en Kex-algoritmen in Nexus-platforms.
Cisco raadt je aan om 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.
Soms kunnen beveiligingsscans zwakke coderingsmethoden vinden die worden gebruikt door Nexus-apparaten. Als dit gebeurt, zijn wijzigingen in hetdcos_sshd_config
bestand op de switches vereist om deze onveilige algoritmen te verwijderen.
Om te bevestigen welke Ciphers, MAC's en Kex-algoritmen een platform gebruikt en dit te controleren vanaf een extern apparaat, kunt u deze opties gebruiken:
Open een CMD-lijn op een pc die het Nexus-apparaat kan bereiken en gebruik de opdracht 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
Dit geldt voor:
Stappen:
switch(config)# feature bash-shell
switch(config)#
switch(config)# run bash
bash-4.3$
2. Bekijk de inhoud van hetdcos_sshd_config
bestand:
bash-4.3$ cat /isan/etc/dcos_sshd_config
Opmerking: u kunt egrep gebruiken om naar specifieke lijnen te kijken: cat /isan/etc/dcos_sshd_config | grep MAC
Dit geldt voor:
Stappen:
1. Open een TAC-case 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, zodat alleen de kopie wordt verwijderd nadat de dplug is geladen en het oorspronkelijke dplug-bestand in bootflash blijft voor volgende runs.
3. Laad de kopie van de dplug via deload
opdracht.
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
Bestand bekijken.
Linux(debug)# cat /isan/etc/dcos_sshd_config
1. Stuur een kopie van hetdcos_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 op bootflash staat:
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. Breng de nodige wijzigingen aan in het bestand en importeer het opnieuw in bootflash.
1. Upload het gewijzigdedcos_sshd_config
bestand om Flash op te starten.
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 bestand onderdcos_sshd_config
/isan/etc/
te vervangen door een gewijzigd bestand datdcos_sshd_config
zich in bootflash bevindt. Dit proces is niet persistent bij het opnieuw opstarten
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)# moet u het bestaande bestand overschrijvendcos_sshd_config
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 dat wordt geactiveerd wanneer het log "VDC_MGR-2-VDC_ONLINE" na een herladen verschijnt. Als de EEM wordt geactiveerd, wordt een pyroscript uitgevoerd en wordt het bestaandedcos_sshd_config
bestand onder/isan/etc/
vervangen door een gewijzigddcos_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 payscript waarin wijzigingen in hetdcos_sshd_config
bestand worden toegepast. 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. Controleer of de bestandsnaamdcos_sshd_config
van het script en de bootflash (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#
4. Voer het script eenmaal uit, zodat het bestanddcos_sshd_config
wordt gewijzigd.
switch# source ssh_workaround_7k.py
switch#
5. Configureer een EEM-script, zodat het py-script wordt uitgevoerd telkens wanneer de switch opnieuw wordt opgestart en weer omhoog komt.
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 "actie <id> cli" en andere "actie <id> cli-opdracht"), dus zorg ervoor dat u controleert of de EEM-opdrachten correct worden uitgevoerd.
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 payscript waarin wijzigingen in hetdcos_sshd_config
bestand worden toegepast. 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. Controleer of de bestandsnaamdcos_sshd_config
van het script en van bootflash (stap 1.) hetzelfde is:
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#
4. Voer het script eenmaal uit, zodat het bestanddcos_sshd_config
wordt gewijzigd.
switch# python bootflash:ssh_workaround_9k.py
5. Configureer een EEM-script, zodat het py-script wordt uitgevoerd telkens wanneer de switch opnieuw wordt opgestart en weer omhoog komt.
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 "actie <id> cli" en andere "actie <id> cli-opdracht"), dus zorg ervoor dat u controleert of de EEM-opdrachten correct worden uitgevoerd.
Een gewijzigd dplug-bestand is gemaakt via Cisco bug ID CSCvr23488 om deze Kex-algoritmen te verwijderen:
De dpug-bestanden die worden geleverd via Cisco bug ID CSCvr23488 zijn niet dezelfde als die worden gebruikt om toegang te krijgen tot de Linux Shell. Open een TAC-case om de aangepaste dplug te verkrijgen van Cisco bug ID CSCvr23488.
dcos_sshd_config
instellingen: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. 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, zodat alleen de kopie wordt verwijderd nadat de dplug is geladen en het oorspronkelijke dplug-bestand in bootflash blijft 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 nieuwedcos_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. Maak deze wijziging persistent 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:
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 voorkomen, typt u in:
bash-4.3$ sudo usermod -s /bin/bash root
Na deze "sudo su" werkt:
bash-4.3$ sudo su
bash-4.3#
Opmerking: deze wijziging overleeft een herlading niet.
dcos_sshd_config
bestand voor elke VDC. Als u SSH-parameters op een andere VDC moet wijzigen, moet u ervoor zorgen dat u het bijbehorendedcos_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
dcos_sshd_config
bestand zijn niet blijvend bij het opnieuw opstarten op een Nexus-platform. Als wijzigingen blijvend moeten zijn, kan een EEM worden gebruikt om het bestand aan te passen telkens wanneer de switch wordt opgestart. 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
Voorbeeld CLI van een switch met 10.3(6):
switch(config)# ssh kexalgos ?
all Enable algorithms supported in current version of SSH
ecdh-sha2-nistp384 Enable ecdh-sha2-nistp384
switch(config)# ssh ciphers ?
aes256-gcm Enable aes256-gcm
all Enable algorithms supported in current version of SSH
switch(config)# ssh macs ?
all Enable algorithms supported in current version of SSH
Er zijn extra Codering-, MAC- en KexAlgoritmes die indien nodig kunnen worden toegevoegd:
switch(config)# ssh kexalgos [all | key-exchangealgorithm-name]
switch(config)# ssh macs [all | mac-name]
switch(config)# ssh ciphers [ all | cipher-name ]
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 release 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 |
---|---|---|
1.0 |
01-Jul-2024
|
Eerste vrijgave |