반응형

구형 cisco 장치의 경우 ssh client와 프로토콜 자동 매칭이 안되서 ssh 에러 메시지가 출력되는 경우가 있다.

내 경우의 해결 방법을 남겨본다. 장치의 IP는 192.168.0.100 으로 가정한다.

1) cisco 장치의 ssh 포트 번호를 찾아보자

    기본 ssh port는 22 이지만, 다른 포트번호로 바꿔둔 경우가 있는데, 찾는 방법이다. 

    리눅스의 nc 명령으로 tcp 포트 범위를 조금씩 스캔해본다. 너무 넓은 범위로 스캔하면 해킹 의심을 받거나 보안 장비에서 차단될 수 있으니, 조금씩 번호를 잘라서 시도해본다.

명령: $  nc -z 192.168.0.100 21-25 
결과: Connection to 192.168.0.100 22 port [tcp/ssh] succeeded!

          설명: 192.168.0.100 장치에 대해서 tcp port 21 부터 25까지 응답을 확인한다.

                  nc -z 옵션은 세션을 맺지않고, listen중인 tcp 포트의 응답만을 확인한다.

                  22 port가 확인되었으니 -p22 옵션을 추가하여 시도해본다.

2) ssh 접속 시도, 그리고 no matching key exchange method found 에러 

명령: $ ssh -p22 username@192.168.0.100
결과: Unable to negotiate with 192.168.0.100 port 22: no matching key exchange method found. 
Their offer: diffie-hellman-group1-sha1

          메시지를 살펴보면 해답이 있는데,

          negotiate를 실패했고, 이유는 key exchange method가 매칭되지 않았다는 것,

          그리고, 장치측에서 권하는 방식은 diffie-hellman-group1-sha1 이라고 설명하고 있다. (친절하네~)

 3) ssh 옵션에 key exchange method 추가하여 접속 시도, 그리고 no matching cipher found 에러

           ssh -oKexAlgorithms  옵션을 추가하여 접속 시도해본다

명령: $ ssh -p22 -oKexAlgorithms=+diffie-hellman-group1-sha1 username@192.168.0.100
결과: Unable to negotiate with 192.168.0.100 port 22: no matching cipher found. 
Their offer: aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc

        negotiate를 실패했고, 이유는 cipher 값이 매칭되지 않았다.

        그리고, 추천 방식은 aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc 라고 설명하네 (정답을 떠 먹여주네~)

        ssh -c 옵션에 cipher 타입 한가지씩 대입하여 시도해보면 되겠다.

4) 위 옵션에 cipher 옵션을 추가하여 접속 시도, 그리고 성공 

명령: $ ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 -c aes128-cbc username@192.168.0.100
결과: The authenticity of host '192.168.0.100' can't be established.
RSA key fingerprint is SHA256:jgyvlRU10DKdo03ku5p5ilL48.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes

            메시지에서 "can't be established" 이 부분은 이 클라이언트와 처음 접속한다는 의미라서 에러가 아니다.

            Are you sure you want to continue connecting (yes/no/[fingerprint])?   이 질문은 yes 입력하면 되겠지.

이어지는 메시지
Warning: Permanently added '192.168.0.100' (RSA) to the list of known hosts.
(username@192.168.0.100) Password: "password를 입력한다"
 
"WARNING: Unauthorized access to this system is
forbidden and will be prosecuted by law.
By accessing this system, you agree that
your actions may be monitored
if unauthorized usage is suspected."

cisco_switch>

접속 성공!!

반응형

+ Recent posts