
저는 Hadoop을 배우고 있으며 책에 정의된 절차에 따라 비밀번호 없는 SSH를 생성하려고 합니다.Hadoop: 최종 가이드
SSH 구성
의사 분산 모드는 (단일) 호스트가 localhost인 완전 분산 모드의 특별한 경우이므로 비밀번호를 입력하지 않고도 localhost에 SSH를 통해 로그인할 수 있는지 확인해야 합니다.
먼저 SSH가 설치되어 있는지 확인하세요. 서버가 실행 중입니다.(나는 이것이 무엇을 의미하는지 잘 모르겠습니다). 예를 들어 Ubuntu에서는 다음을 사용하여 이를 달성합니다.
sudo apt-get install ssh
그런 다음 비밀번호 없는 로그인을 활성화하려면 빈 비밀번호 문구를 사용하여 새 SSH 키를 생성하세요.
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
실행해야 할 수도 있습니다.SSH 추가ssh-agent.Test를 실행 중인 경우 다음과 같이 연결할 수 있습니다.
ssh localhost
성공하면 비밀번호를 입력할 필요가 없습니다.
모든 것이 잘 작동하는 것 같지만 여전히 비밀번호를 묻습니다. 루트 액세스에도 사용하는 로그인 비밀번호를 제공하겠습니다. 하지만 전혀 작동하지 않습니다. 제안해주세요.
더 많은 정보를 추가합니다. 이전 키를 삭제하고 새 키를 추가했습니다.
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
이후 내 파일 권한은 다음과 같습니다.
-rw-rw-r-- 1 incredible incredible 403 मई 24 17:16 authorized_keys
-rw------- 1 incredible incredible 1679 मई 23 23:08 id_rsa
-rw-r--r-- 1 incredible incredible 403 मई 23 23:08 id_rsa.pub
-rw-r--r-- 1 incredible incredible 444 मई 24 17:12 known_hosts
Authorized_key의 권한을 변경한 후
-rw------- 1 incredible incredible 403 मई 24 17:16 authorized_keys
-rw------- 1 incredible incredible 1679 मई 23 23:08 id_rsa
-rw-r--r-- 1 incredible incredible 403 मई 23 23:08 id_rsa.pub
-rw-r--r-- 1 incredible incredible 444 मई 24 17:12 known_hosts
그런데 그 이후에도 비밀번호를 물어보네요.ssh localhost
ssh -v localhost
@heemayl이 요청한 추가 정보 출력 추가
incredible@incredible:~$ ssh -v localhost OpenSSH_6.7p1 Ubuntu-5ubuntu1, OpenSSL 1.0.1f 6 Jan 2014 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug1: Connecting to localhost [127.0.0.1] port 22. debug1: Connection established. debug1: identity file /home/incredible/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /home/incredible/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/incredible/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/incredible/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/incredible/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/incredible/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/incredible/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/incredible/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_6.7p1 Ubuntu-5ubuntu1 debug1: Remote protocol version 2.0, remote software version OpenSSH_6.7p1 Ubuntu-5ubuntu1 debug1: match: OpenSSH_6.7p1 Ubuntu-5ubuntu1 pat OpenSSH* compat 0x04000000 debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client aes128-ctr [email protected] none debug1: kex: client->server aes128-ctr [email protected] none debug1: sending SSH2_MSG_KEX_ECDH_INIT debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ECDSA 3c:e1:36:10:30:19:b3:e1:43:73:a5:6c:76:9e:24:67 debug1: Host 'localhost' is known and matches the ECDSA host key. debug1: Found key in /home/incredible/.ssh/known_hosts:1 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,keyboard-interactive debug1: Next authentication method: publickey debug1: Offering RSA public key: /home/incredible/.ssh/id_rsa debug1: Authentications that can continue: publickey,password,keyboard-interactive debug1: Trying private key: /home/incredible/.ssh/id_dsa debug1: Trying private key: /home/incredible/.ssh/id_ecdsa debug1: Trying private key: /home/incredible/.ssh/id_ed25519 debug1: Next authentication method: keyboard-interactive debug1: Authentications that can continue: publickey,password,keyboard-interactive debug1: Next authentication method: password incredible@localhost's password:
@heemayl : 다음은 출력입니다ssh -vvv localhost
debug1: Offering RSA public key: /home/incredible/.ssh/id_rsa debug3: send_pubkey_test debug2: we sent a publickey packet, wait for reply debug1: Authentications that can continue: publickey,password,keyboard-interactive debug1: Offering RSA public key: incredible@incredible debug3: send_pubkey_test debug2: we sent a publickey packet, wait for reply debug1: Authentications that can continue: publickey,password,keyboard-interactive debug1: Trying private key: /home/incredible/.ssh/id_dsa debug3: no such identity: /home/incredible/.ssh/id_dsa: No such file or directory debug1: Trying private key: /home/incredible/.ssh/id_ecdsa debug3: no such identity: /home/incredible/.ssh/id_ecdsa: No such file or directory debug1: Trying private key: /home/incredible/.ssh/id_ed25519 debug3: no such identity: /home/incredible/.ssh/id_ed25519: No such file or directory debug2: we did not send a packet, disable method debug3: authmethod_lookup keyboard-interactive debug3: remaining preferred: password debug3: authmethod_is_enabled keyboard-interactive debug1: Next authentication method: keyboard-interactive debug2: userauth_kbdint debug2: we sent a keyboard-interactive packet, wait for reply debug1: Authentications that can continue: publickey,password,keyboard-interactive debug3: userauth_kbdint: disable: no info_req_seen debug2: we did not send a packet, disable method debug3: authmethod_lookup password debug3: remaining preferred: debug3: authmethod_is_enabled password debug1: Next authentication method: password incredible@localhost's password:
답변1
문제는 파일의 권한으로 인해 발생합니다 ~/.ssh/authorized_keys
. 다른 사람이 파일에 쓸 수 있도록 권한을 부여해서는 안 됩니다.
예를 들어 권한이 8진수로 설정된 경우 666
(실제로 악마입니다!!) 다른 모든 사람이 파일에 쓰기 권한을 가질 수 있으므로 ~/.ssh/authorized_keys
해당 파일은 무시되고 ssh
비밀번호를 묻는 메시지가 표시됩니다.
파일이 ~/.ssh/authorized_keys
미리 존재하지 않는다고 가정하면 다음 명령
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
~/.ssh/authorized_keys
값 에 따라 결정된 권한으로 파일을 만든 umask
다음 파일 내용을 추가합니다 ~/.ssh/id_rsa.pub
.
따라서 해결책은 파일의 권한을 변경하여 사용자만 쓸 수 있도록 하는 것입니다. 예를 들면 다음과 같습니다.
chmod 600 ~/.ssh/authorized_keys