SSH KexAlgorithms 지정은 CLI에서 작동하지만 ssh_config를 통해서는 작동하지 않습니다.

SSH KexAlgorithms 지정은 CLI에서 작동하지만 ssh_config를 통해서는 작동하지 않습니다.

diffie-hellman-group-exchange-sha256기본적으로 내 SSH 클라이언트는 키 교환 알고리즘 의 사용을 허용하지 않습니다 . 하지만 이 알고리즘을 사용해야 하는 10.0.0.1의 서버에 액세스해야 합니다.

이것은 명령줄에서 잘 작동합니다.

$ ssh -o KexAlgorithms=diffie-hellman-group-exchange-sha256 [email protected]
Password:

그러나 마지막에 다음을 추가하려고 하면 실패합니다 /etc/ssh/ssh_config.

Host 10.0.0.1
    KexAlgorithms diffie-hellman-group-exchange-sha256

관련 출력은 다음과 같습니다.

$ ssh -vvv [email protected]
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug3: kex names ok: [[email protected]]
...
debug1: /etc/ssh/ssh_config line 72: Applying options for 10.0.0.1
debug3: kex names ok: [diffie-hellman-group-exchange-sha256]
...
debug1: Connecting to 10.0.0.1 [10.0.0.1] port 22.
debug1: Connection established.
...
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: [email protected]
...
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256
...
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: mac_setup: setup hmac-ripemd160
debug1: kex: server->client aes256-ctr hmac-ripemd160 none
debug2: mac_setup: setup hmac-ripemd160
debug1: kex: client->server aes256-ctr hmac-ripemd160 none
Unable to negotiate a key exchange method

이것에 대해 나를 혼란스럽게 하는 것은 SSH가 관련 줄을 명확하게 읽고 /etc/ssh/ssh_config그것에 만족해 보인다는 것입니다. 그러나 [email protected]서버와 키 교환을 협상하는 대신 을 사용하려고 시도하지만 diffie-hellman-group-exchange-sha256당연히 실패합니다.

왜 이런 일이 발생하며 어떻게 해결할 수 있나요?

답변1

언뜻 보면 OpenSSH 옵션이 조금 이상해 보일 수 있습니다. 그러나 매뉴얼 페이지에는 ssh_config이에 대한 내용이 잘 설명되어 있습니다.

각 매개변수에 대해 처음 얻은 값이 사용됩니다.. 구성 파일에는 "호스트" 사양으로 구분된 섹션이 포함되어 있으며, 이 섹션은 사양에 제공된 패턴 중 하나와 일치하는 호스트에만 적용됩니다. 일치하는 호스트 이름은 일반적으로 명령줄에 제공된 호스트 이름입니다(예외에 대해서는 CanonicalizeHostname 옵션 참조).

필요한 것을 달성하기 위해 다음과 같이 구성을 다시 작성할 수 있습니다(별 *일치는 마지막 항목이어야 합니다).

Host 10.0.0.1
    KexAlgorithms diffie-hellman-group-exchange-sha256
#[...]
Host *
    KexAlgorithms [email protected]

내 답변이 중복되었습니다.

그리고 동일한 매뉴얼 페이지에서 명령줄 옵션이 작동하는 이유에 대한 설명도 제공됩니다 ssh_config.

  1. 명령줄 옵션
  2. 사용자 구성 파일(~/.ssh/config)
  3. 시스템 전체 구성 파일(/etc/ssh/ssh_config)

관련 정보