문제: 요새 호스트 IP 불일치~/.ssh/known_hosts

문제: 요새 호스트 IP 불일치~/.ssh/known_hosts

Mac에서 원격 서버에 대한 비밀번호 없는 SSH 연결을 만들었습니다. 작동했습니다(!). 그런 다음 터미널을 닫았다가 다시 열고 다시 시도한 결과 다음과 같은 결과를 얻었습니다(사용자 이름, my_ip는 실제가 아닙니다).

ssh -vvv username@my_ip
OpenSSH_7.2p2, LibreSSL 2.4.1
debug1: Reading configuration data /Users/Me/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 20: Applying options for *
debug1: /etc/ssh/ssh_config line 53: Applying options for *
debug2: resolving "my_ip" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to my_ip [my_ip] port 22.
debug1: Connection established.
debug1: identity file /Users/Me/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/Me/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/Me/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/Mes/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/Me/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/Me/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/Me/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/Me/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2
ssh_exchange_identification: read: Connection reset by peer

.ssh폴더를 확인해 보니 id_rsa거기에 있지만 다른 것은 없습니다. 오류를 보면 어떻게든 이 파일을 생성해야 할 것 같지만 어떻게 해야 할지 모르겠습니다.

어떤 도움이라도 대단히 감사하겠습니다.

답변1

debug1: key_load_public: No such file or directory

위의 줄은 오류가 아니며 ssh클라이언트가 개별 공개 키( 이름이 지정됨 ~/.ssh/id_rsa.pub)를 찾을 수 없음을 나타내는 단순한 디버그 로그입니다. 이 파일은 원격 서버에 대한 연결이 필요하지 않지만 유용합니다.

실제 오류

ssh_exchange_identification: read: Connection reset by peer

서버 구성 오류를 가리킵니다. 서버가 실행 중이지만 SSH 연결을 수락할 수 없습니다. 자세한 내용은 서버 로그를 확인하세요.유제

답변2

문제: 요새 호스트 IP 불일치~/.ssh/known_hosts

known_hosts요새의 IP 주소가 변경되어 파일이 오래되었습니다 .

$ ssh 10.82.49.24
ssh_exchange_identification: Connection closed by remote host

나에게 어떤 정보도 제공되지 않았습니다. 자세한 출력을 보면 동일한 결과가 나타납니다.

$ ssh -v 10.82.49.24
OpenSSH_7.4p1, LibreSSL 2.5.0
debug1: Reading configuration data /Users/mdesales/.ssh/config
debug1: /Users/mdesales/.ssh/config line 1: Applying options for 10.82.*.*
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Executing proxy command: exec ssh -q -W 10.82.49.24:22 [email protected] -i ~/.ssh/xxxconfig-xxxx.pem
debug1: key_load_public: No such file or directory
debug1: identity file ~/.ssh/xxxconfig-xxxx.pem
debug1: key_load_public: No such file or directory
debug1: identity file ~/.ssh/xxxconfig-xxxx.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: permanently_drop_suid: 1647059022
ssh_exchange_identification: Connection closed by remote host

이 시점에서는 요새를 통해 다른 호스트로의 프록시이기 때문에 요새에 문제가 있음을 알 수 있습니다.

$ ssh [email protected] -i ~/.ssh/xxxconfig-xxxx.pem
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:Z8X1UlIgQ94BKJ7NA/oQi7v0NL4IlFeO7Ou4j76Zphk.
Please contact your system administrator.
Add correct host key in /Users/mdesales/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/mdesales/.ssh/known_hosts:238
ECDSA host key for [email protected] has changed and you have requested strict checking.
Host key verification failed.

해결책

238행에서 항목을 제거하면 문제가 해결되었습니다. 요새로 SSH를 통해 연결할 수 있고 호스트로 SSH로 연결할 수 있습니다.

$ vim /Users/mdesales/.ssh/known_hosts

$ ssh [email protected] -i ~/.ssh/xxxconfig-xxxx.pem
The authenticity of host '[email protected] (34.x.x.y)' can't be established.
ECDSA key fingerprint is SHA256:Z8X1UlIgQ94BKJ7NA/oQi7v0NL4IlFeO7Ou4j76Zphk.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[email protected] -i ~/.ssh/xxxconfig-xxxx.pem,34.213.y.x' (ECDSA) to the list of known hosts.
********************************************************************************
This is a private computer system containing information that is proprietary
and confidential to the owner of the system.  Only individuals or entities
authorized by the owner of the system are allowed to access or use the system.
Any unauthorized access or use of the system or information is strictly
prohibited.

All violators will be prosecuted to the fullest extent permitted by law.
********************************************************************************
Last login: Wed Aug  2 20:35:55 2017 from 10.81.31.115
[ec2-user@ip-10-82-50-142 ~]$ 

답변3

같은 문제가 있습니다. 그녀는 이렇게 결정했습니다.

chmod 0600 /home/<user>/.ssh/*

답변4

오늘 나에게 일어났습니다.

WLAN 연결을 끊었다가 다시 연결하여 문제가 해결되었습니다. 예, 어리석게 들리지만 적어도 하나의 WLAN에서는 아무 이유 없이 이런 일이 발생합니다.

관련 정보