SSH는 절대 비밀번호를 묻지 않습니다

SSH는 절대 비밀번호를 묻지 않습니다

어떻게 든 내 SSH는 나에게 비밀번호를 묻고 싶어하지 않습니다.

그래서 전 세계 어딘가에 있는 임의의 서버에 VPS를 설정하고 SSH로 연결하고 싶습니다.

키를 설정할 수 있지만 이렇게 하면 다음과 같습니다.

ssh -l some-user IP

오류가 발생합니다.

Received disconnect from ##.##.##.##: 2: Too many authentication failures for some-user

세부정보를 보면 비밀번호가 옵션 중 하나라는 것을 알 수 있습니다.

debug1: Offering RSA public key: some-user@computer
debug1: Authentications that can continue: publickey,password

그러나 SSH는 나에게 비밀번호를 묻지 않습니다. 공개키 방식인 것으로 의심되는 방식으로 5번 시도한 후 실패합니다. SSH가 비밀번호를 사용하지 않는 이유는 무엇입니까?!

혹시라도 내 ssh_config 파일에는 다음이 있습니다.

PasswordAuthentication yes

전체 로그

ssh -v -l root ##.##.##.##
OpenSSH_6.1p1 Debian-4, OpenSSL 1.0.1c 10 May 2012
debug1: Reading configuration data /home/someuser/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to ##.##.##.## [##.##.##.##] port 22.
debug1: Connection established.
debug1: identity file /home/someuser/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /home/someuser/.ssh/id_rsa-cert type -1
debug1: identity file /home/someuser/.ssh/id_dsa type -1
debug1: identity file /home/someuser/.ssh/id_dsa-cert type -1
debug1: identity file /home/someuser/.ssh/id_ecdsa type -1
debug1: identity file /home/someuser/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.2p2 Ubuntu-6
debug1: match: OpenSSH_6.2p2 Ubuntu-6 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.1p1 Debian-4
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA XX:XX:...:XX:XX
debug1: Host '##.##.##.##' is known and matches the ECDSA host key.
debug1: Found key in /home/someuser/.ssh/known_hosts:38
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/someuser/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: someuser@computer
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: someuser@computer
debug1: Authentications that can continue: publickey,password
debug1: Offering DSA public key: someuser@computer
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: someuser@computer
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: someuser@computer
Received disconnect from ##.##.##.##: 2: Too many authentication failures for root

답변1

다음을 사용하여 공개 키 인증을 비활성화한 상태에서 로그인을 시도합니다.

ssh -o PubkeyAuthentication=no root@newserver

답변2

identityfile아마도 파일 에 두 개 이상의 줄이 있을 것입니다 .ssh/config.

identityfileUnder Configuration이 있어도 host전역적으로 적용됩니다. 이는 ssh서버에서 비밀번호 프롬프트를 요청하기 전에 모든 호스트에서 모든 ID 파일(예: 공개 키)을 시도한다는 의미입니다 .

이 문제를 해결할 수 있습니다.

  1. 한 줄만 남기고 모두 제거 identityfile하거나
  2. PubkeyAuthentication no에 추가 .ssh/config또는
  3. 매개변수를 사용하여 SSH를 실행 중입니다 -o PubkeyAuthentication=no.

에서 man 5 ssh_config:

PubkeyAuthentication
    Specifies whether to try public key authentication.  The argument to this
    keyword must be “yes” or “no”.  The default is “yes”.  This option applies 
    to protocol version 2 only.

IdentityFile
    ...
    It is possible to have multiple identity files specified in configuration
    files; all these identities will be tried in sequence.  Multiple 
    IdentityFile directives will add to the list of identities tried (this 
    behaviour differs from that of other configuration directives).

공개 키에 대한 몇 가지 일반적인 지침은 다음과 같습니다.

  1. 일반적으로 클라이언트(워크스테이션)당 하나의 개인 키만 보유해야 하며, 클라이언트가 액세스해야 하는 모든 서버에 일치하는 공개 키를 넣어야 합니다. 즉, 서버 간에 공개 키를 공유하고, 여러 장치에서 동일한 개인 키를 사용하지 마십시오.
  2. 항상 장치에서 키 쌍을 생성하고 공개 키만 전송하십시오. 이렇게 하면 서버가 손상되더라도 개인 키는 여전히 안전합니다. 이는 백업과 같은 놀라운 방법으로 발생할 수 있습니다.
  3. 다른 사람이 서버를 관리하는 경우그들에게 공개 키를 제공해야 합니다. 그들은해야~ 아니다키 쌍을 생성하고 개인 키를 귀하에게 보냅니다. 이렇게 하면 그들은 귀하의 키를 가지고 귀하를 가장할 수 없습니다(물론 일반적으로 그들은 원하는 것은 무엇이든 할 수 있습니다). 또한 공개 키를 사용하면 무결성(즉, 누군가가 공개 키를 변경하지 않은 경우)만 보호되어야 합니다. 개인 키를 사용하면 기밀성(즉, 다른 사람이 키를 얻지 못함)이 보존되어야 하며 이것이 손상되지 않았는지 절대적으로 확신할 수 없습니다.
  4. 여러 서버에 연결하는 데 동일한 개인 키를 사용하더라도 서버를 손상해도 다른 서버는 손상되지 않습니다(해당 개인 키를 서버에 전송한 경우는 제외됩니다. 절대 그렇게 하지 마십시오).
  5. 워크스테이션을 손상시키면 어쨌든 개인 키가 노출됩니다. 개인 키가 여러 개 있으면 도움이 되지 않습니다(다양하고 강력한 암호 문구가 있고 공격자가 해당 암호를 모두 사용할 수 없는 경우는 제외).

여기에는 몇 가지 예외가 있지만 너무 많지는 않습니다.

답변3

귀하의 로컬 SSH는 비밀번호를 요구해서는 안 되며, 반대편의 SSH 서버는 그래야 합니다. 서버가 비밀번호 인증을 허용하지 않도록 설정되었을 가능성이 높습니다. 내 것도 비밀번호를 묻지 않을 것입니다.

답변4

내가 찾은 또 다른 원인. 나는 가지고 있었다 :

Host *
   PreferredAuthentications publickey

in ~/.ssh/config(다른 사용자가 "기본 설정"이라고 생각하여 복사함). 실제로 PreferredAuthentications"허용되는" 방법과 순서를 지정합니다.

해당 줄을 삭제 PreferredAuthentications하거나 추가하세요.password

Host *
   PreferredAuthentications publickey,password

참고: 쉼표 뒤에는 공백이 없습니다!

관련 정보