서버로 SSH를 시도하고 key_load_public 가져 오기 : 해당 파일 또는 디렉토리 오류가 없습니다.


43

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
실제 문제가 있습니까? 예를 들어 실제로 로그인에 실패하고 있습니까? 첫 번째 부분 대신 완전한 디버그 출력을 포함하도록 질문을 편집 할 수 있습니까?
Kenster

예; 사과드립니다! 로그인 할 수 없으며, 마지막 (아마도 가장 중요한?) 줄을 먼저 종료했습니다.
Eric

답변:


51
debug1: key_load_public: No such file or directory

위의 줄은 오류가 아니라 ssh클라이언트가 별도의 공개 키 ( ~/.ssh/id_rsa.pub) 를 찾을 수 없다는 간단한 디버그 로그 입니다. 이 파일은 원격 서버에 연결하는 데 필요하지 않지만 유용 할 수 있습니다.

실제 오차

ssh_exchange_identification: read: Connection reset by peer

서버 구성에서 오류를 가리 킵니다. 서버가 실행 중이지만 SSH 연결을 수락하지 못합니다. 자세한 정보는 서버 로그를 확인하십시오. 비슷한 문제


그 링크는 매우 도움이되었습니다. 그리고 실제로 블랙리스트에 올랐습니다. (내가 무언가를 테스트하는 동안 서버에 너무 많은 시간을 쏟아 부었습니다.)
Eric

1
내 문제는 요새 호스트가 IP 주소를 변경했고 known_hosts내 Mac에서 잘못되었다는 것입니다 ... 그것은 @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @...로 표시되었습니다 ~/.ssh/known_hosts:238. 그래서 나는 Mac의 known_hosts 파일에서 238 줄을 제거하고 성공적으로 다시 연결하려고했습니다.
Marcello de Sales

3

문제 : 요새 호스트 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 ec2-user@bastion-vpc-xxxxxx.config-yyyyyyy.com -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 ec2-user@bastion-vpc-xxxxxx.config-yyyyyyy.com -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 ec2-user@bastion-vpc-xxxxxx.config-yyyyyyy.com has changed and you have requested strict checking.
Host key verification failed.

해결책

238 번 줄에서 항목을 제거하면 문제가 해결되었습니다. 요새로 ssh하고 호스트로 ssh 할 수 있습니다.

$ vim /Users/mdesales/.ssh/known_hosts

$ ssh ec2-user@bastion-vpc-xxxxxx.config-yyyyyyy.com -i ~/.ssh/xxxconfig-xxxx.pem
The authenticity of host 'ec2-user@bastion-vpc-xxxxxx.config-yyyyyyy.com (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 'ec2-user@bastion-vpc-xxxxxx.config-yyyyyyy.com -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 ~]$ 

1

오늘 나에게 일어났다.

WLAN 연결을 끊고 다시 연결하여 수정했습니다. 예, 어리석은 소리와 어리석은 소리이지만 적어도 하나의 WLAN에서는 아무런 이유없이 발생했습니다.


0

같은 문제, 여기에 솔루션을 게시하십시오.

다음을 /etc/hosts.deny사용하여 IP를 제거하십시오 .

nano /etc/hosts.deny
당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.