이 문서에서는 Nexus 플랫폼에서 암호, MAC 및 Kex 알고리즘을 추가(또는 제거)하는 단계에 대해 설명합니다.
Linux 및 Bash의 기본 사항을 이해하는 것이 좋습니다.
이 문서의 정보는 다음 하드웨어 및 소프트웨어 버전을 기반으로 합니다.
이 문서의 정보는 특정 랩 환경의 디바이스를 토대로 작성되었습니다. 이 문서에 사용된 모든 디바이스는 초기화된(기본) 컨피그레이션으로 시작되었습니다. 현재 네트워크가 작동 중인 경우 모든 명령의 잠재적인 영향을 미리 숙지하시기 바랍니다.
일부 보안 스캔에서는 Nexus 디바이스에서 사용하는 취약한 암호화 방법을 찾을 수 있습니다. 이 경우 안전하지 않은 알고리즘을 제거하려면 스위치에서 dcos_sshd_config 파일을 변경해야 합니다.
플랫폼이 사용하는 암호, MAC 및 Kex 알고리즘을 확인하려면 외부 장치에서 이를 확인합니다. 다음 옵션을 사용할 수 있습니다.
Nexus 디바이스에 연결할 수 있는 PC에서 CMD 줄을 열고 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-shell 기능을 활성화하고 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 파일을 bootflash에 업로드하고 복사본을 만듭니다.
switch# copy bootflash:nuova-or-dplug-mzg.7.3.8.N1.1 bootflash:dp
참고: 원래 dplug 파일의 복사본("dp")이 bootflash에 작성되므로, dplug가 로드된 후에만 복사본이 제거되고 이후 실행을 위해 원래 dplug 파일은 bootflash에 남아 있습니다.
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. 복사본이 bootflash에 있는지 확인합니다.
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. 필요한 경우 파일을 변경하고 bootflash로 다시 가져옵니다.
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#
기존 dcos_sshd_config 파일 /isan/etc/를 bootflash에 있는 수정된 dcos_sshd_config 파일로 교체합니다. 이 프로세스는 재부팅 시에도 지속되지 않습니다
ssh configbootflash에 업로드: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 파일을 bootflash에 있는 수정된 dcos_sshd_config 파일로 대체합니다. 이는 "feature 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 스크립트를 bootflash에 업로드합니다.
switch# dir bootflash:///scripts
175 Mar 03 16:11:01 2023 ssh_workaround_7k.py
참고: Python 스크립트는 Cisco 버그 ID CSCva14865를 극복하기 위한 몇 가지 추가 라인이 포함된 N7K를 제외하고 모든 플랫폼에서 거의 동일합니다.
4. 스크립트 및 bootflash의 dcos_sshd_config 파일 이름이 동일한지 확인합니다(단계 1).
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. 스크립트를 한 번 실행하여 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 스크립트를 bootflash에 업로드합니다.
switch# dir | i i .py
127 Jun 18 17:21:39 2024 ssh_workaround_9k.py
switch#
4. 스크립트 및 bootflash의 dcos_sshd_config 파일 이름이 동일한지 확인합니다(1단계).
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. 스크립트를 한 번 실행하여 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 명령이 정확한지 확인합니다.
Cisco 버그 ID CSCvr23488을 통해 수정된 dplug 파일을 생성하여 다음 Kex 알고리즘을 제거했습니다.
Cisco 버그 ID CSCvr23488을 통해 제공되는 dpug 파일은 Linux 셸에 액세스하는 데 사용되는 것과 동일하지 않습니다. TAC 케이스를 열어 Cisco 버그 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")은 bootflash에서 작성되며, dplug가 로드된 후에만 복사본이 제거되고 이후 실행을 위해 원래 dplug 파일은 bootflash에 남아 있습니다.
3. Cisco 버그 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 파일은 bootflash에 있어야 하며 EEM은 적절한 dplug 파일 이름으로 구성해야 합니다. dplug 파일 이름은 스위치 버전에 따라 달라질 수 있으며 필요에 따라 스크립트를 수정해야 합니다. 작업 1은 bootflash에서 원본 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
참고: 이러한 명령은 Nexus 7000 릴리스 8.3(1) 이상에서 사용할 수 있습니다. Nexus 3000/9000 플랫폼의 경우 이 명령을 릴리스 7.0(3)I7(8) 이상에서 사용할 수 있습니다. (모든 9.3(x) 릴리스에도 이 명령이 있습니다. Cisco Nexus 9000 Series NX-OS 보안 컨피그레이션 가이드, 릴리스 9.3(x)를 참조하십시오.
| 개정 | 게시 날짜 | 의견 |
|---|---|---|
2.0 |
31-Jul-2026
|
맞춤법, 문법, 제목, 삽입된 가로선을 별도의 섹션/가독성으로 업데이트하고 CCW 알림을 고정합니다. |
1.0 |
01-Jul-2024
|
최초 릴리스 |