나는 보통 사용한다테미우스Mac에서 Debian 서버로 SSH를 통해 연결했는데 지금까지는 훌륭하게 작동했습니다. 이제 단지 호기심에서 제3자가 개입하지 않고 내장된 Mac SSH 클라이언트를 사용해 보았습니다.
내용은 이렇습니다~/.ssh/config내 Mac에서:
Host stalingrad
Hostname xxx.xxx.xxx.xxx
User root
Port 22
IdentityFile ~/.ssh/digital_ocean_id_rsa.pub
IdentitiesOnly yes
내 맥을 확인해 봤는데~/.ssh/digital_ocean_id_rsa.pub내 Debian 상자와 일치합니다./root/.ssh/authorized_keys
또한 VPS에서 다음 명령을 실행하십시오.
$ chmod 700 /root/.ssh
$ chmod 600 /root/.ssh/authorized_keys
$ /etc/init.d/ssh restart
좋아, SSH를 시도해 보자:
ssh [email protected]
나는 이것을 얻었다:
debug1: Will attempt key: /Users/andre/.ssh/id_rsa RSA SHA256:xxxxxxxxxxxxxxxx
debug1: Will attempt key: /Users/andre/.ssh/id_ecdsa
debug1: Will attempt key: /Users/andre/.ssh/id_ecdsa_sk
debug1: Will attempt key: /Users/andre/.ssh/id_ed25519
debug1: Will attempt key: /Users/andre/.ssh/id_ed25519_sk
debug1: Will attempt key: /Users/andre/.ssh/id_xmss
debug1: Will attempt key: /Users/andre/.ssh/id_dsa
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected]>
debug1: kex_input_ext_info: [email protected]=<0>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /Users/andre/.ssh/id_rsa RSA SHA256:xxxxxxxxxxxxxxxx
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/andre/.ssh/id_ecdsa
debug1: Trying private key: /Users/andre/.ssh/id_ecdsa_sk
debug1: Trying private key: /Users/andre/.ssh/id_ed25519
debug1: Trying private key: /Users/andre/.ssh/id_ed25519_sk
debug1: Trying private key: /Users/andre/.ssh/id_xmss
debug1: Trying private key: /Users/andre/.ssh/id_dsa
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey).
이것이 내용이다/var/log/auth.logVPS에서:
Oct 31 14:58:29 stalingrad sshd[249851]: error: kex_exchange_identification: Connection closed by remote host
Oct 31 14:58:29 stalingrad sshd[249851]: Connection closed by xxx.xxx.xxx.xxx port 52960
Oct 31 14:58:50 stalingrad sshd[253607]: Connection closed by authenticating user root yyy.yyy.yyy.yyy port 60773 [preauth]
Oct 31 14:58:59 stalingrad sshd[254173]: error: kex_exchange_identification: Connection closed by remote host
Oct 31 14:58:59 stalingrad sshd[254173]: Connection closed by xxx.xxx.xxx.xxx port 57792
Oct 31 14:59:27 stalingrad sshd[254174]: Received disconnect from yyy.yyy.yyy.yyy port 60774:11: Normal Shutdown [preauth]
Oct 31 14:59:27 stalingrad sshd[254174]: Disconnected from authenticating user root yyy.yyy.yyy.yyy port 60774 [preauth]
Oct 31 14:59:29 stalingrad sshd[254176]: error: kex_exchange_identification: Connection closed by remote host
Oct 31 14:59:29 stalingrad sshd[254176]: Connection closed by xxx.xxx.xxx.xxx port 34386
Oct 31 14:59:49 stalingrad sshd[254177]: Connection closed by authenticating user root yyy.yyy.yyy.yyy port 60777 [preauth]
Oct 31 14:59:59 stalingrad sshd[254180]: error: kex_exchange_identification: Connection closed by remote host
Oct 31 14:59:59 stalingrad sshd[254180]: Connection closed by xxx.xxx.xxx.xxx port 39216
SSH가 지정된 개인 키 파일을 읽지 못한 것 같습니다.number_ocean_id_rsa. 대신 이름이 "id_"로 시작하는 개인 키 파일 묶음을 읽으려고 시도합니다. 어떻게 되어가나요?
답변1
공개 키를 IdentityFile로 사용하는 SSH는 없습니다.
공개 키 파일 이름이 아닌 개인 키 파일 이름을 사용해야 합니다.
Host stalingrad
Hostname xxx.xxx.xxx.xxx
User root
Port 22
IdentityFile ~/.ssh/digital_ocean_id_rsa
IdentitiesOnly yes