~/.ssh/config 호스트 이름과 /etc/hosts 간의 충돌 시 우선 순위는 무엇입니까?

~/.ssh/config 호스트 이름과 /etc/hosts 간의 충돌 시 우선 순위는 무엇입니까?

하나의 호스트가 다음과 같이 정의되면 어떻게 될까요 /etc/hosts?

192.168.0.100   server

하나는 다음과 같이 정의됩니다 ~/.ssh/config.

 Host    server
         HostName    192.168.0.101

그리고 당신은 server: 에 ssh를 접속합니다 ssh server.

그러한 갈등은 어떻게 해결될 것인가? 한 쪽이 다른 쪽보다 우선순위가 더 높은 것 같아요.

답변1

그렇게 하면 ssh server서버 부분은 실제 호스트 이름이거나 일부 SSH 내부 "별명"이 될 수 있습니다. ssh는 먼저 .ssh/config에서 별명을 찾습니다. 거기서 구성을 찾으면 이를 사용합니다. 구성을 찾지 못하면 실제 호스트 이름을 가정하고 /etc/host 및 dns를 통해 확인을 시도합니다.

답변2

해당 파일은 ~/.ssh/config와 관련이 없습니다 /etc/hosts. 오히려 ssh존재하는 경우 사용할 구성 파일입니다 .

자세한 스위치 를 ssh사용하여 다른 작업을 수행하기 전에 이 파일을 참조하는 것을 볼 수 있습니다 .-vssh

~/.ssh/config의 호스트 항목

~/.ssh/config여기 "skinner"라는 서버에 대한 내 파일 항목이 있습니다 . 3 -v의 스위치를 포함하여 디버그 레벨 3을 활성화하고 있습니다 .

$ ssh -vvv skinner 
OpenSSH_6.2p2, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /home/saml/.ssh/config
debug1: /home/saml/.ssh/config line 8: Applying options for *
debug1: /home/saml/.ssh/config line 35: Applying options for skinner
debug1: /home/saml/.ssh/config line 55: Applying options for *
debug3: cipher ok: arcfour [arcfour,blowfish-cbc]
debug3: cipher ok: blowfish-cbc [arcfour,blowfish-cbc]
debug3: ciphers ok: [arcfour,blowfish-cbc]
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 50: Applying options for *
debug1: auto-mux: Trying existing master
...

위에서는 ssh이 정의를 사용하고 시스템의 이름 확인 기능을 참조하지도 않는다는 것을 알 수 있습니다.

~/.ssh/config에 호스트 항목이 없습니다.

~/.ssh/config파일 에 해당 항목이 없으면 ssh시스템의 DNS 확인을 참조하여 지정된 호스트 이름에 연결하는 방법을 찾습니다.

$ ssh -vvv skinner
OpenSSH_6.2p2, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /home/saml/.ssh/config
debug1: /home/saml/.ssh/config line 8: Applying options for *
debug1: /home/saml/.ssh/config line 55: Applying options for *
debug3: cipher ok: arcfour [arcfour,blowfish-cbc]
debug3: cipher ok: blowfish-cbc [arcfour,blowfish-cbc]
debug3: ciphers ok: [arcfour,blowfish-cbc]
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 50: Applying options for *
debug1: auto-mux: Trying existing master
debug1: Control socket "/home/saml/.ssh/master-saml@skinner:22" does not exist
debug2: ssh_connect: needpriv 0
debug1: Connecting to skinner [192.168.1.3] port 22.
debug1: Connection established.

ssh여기에서 호스트 이름 "skinner"에 대한 IP 주소를 찾기 위해 시스템을 참조하는 것을 볼 수 있습니다 .

메모:getent시스템에서 호스트 이름을 조회하는 데 사용할 수 있습니다 .

$ getent hosts skinner
192.168.1.3     skinner.dom.net

답변3

일반적으로 Unix 소프트웨어의 경우 사용자별 설정(이 경우 ~/.ssh/config)은 시스템 전체 설정(이 경우 /etc/hosts)보다 우선합니다. 따라서 의 설정이 ~/.ssh/config더 높은 우선순위를 갖습니다.

관련 정보