
및 이라는 이름 KEY
의 키 파일이 있습니다 . 게시글을 에 업로드 하고 비공개를 추가합니다.KEY
KEY.pub
authorized_keys
ssh-add /home/user/.ssh/KEY
그런데 에 연결하려고 하면 계속 비밀번호를 묻는 메시지가 나타납니다.ssh [email protected]
ssh-keygen
기본 키 이름을 사용하여 키를 생성하고 그대로 두고 pub을 업로드하고 개인 키를 로드하면하지 않습니다비밀번호를 요청하세요.
무엇이 문제일까요?
답변1
디버그 출력을 얻을 수 있으며 아마도 (ssh의 기본 키 파일)로 인증할 수 없다는 메시지가 표시될 것 입니다 . 대답은 ssh에 사용할 키를 알려주는 것입니다.ssh -vvv [email protected]
~/.ssh/id_rsa
ssh -i /home/user/.ssh/KEY [email protected]
호스트별 키 파일을 에 추가할 수도 있습니다 .ssh/config
. 그런 다음 입력만 하면 ssh host.com
사용자/키가 자동으로 선택됩니다.
.ssh/config 항목 예시(자세한 내용은 참조 man ssh_config
):
Host mysshserver ssh.host.com
HostName ssh.host.com
User myusername
IdentityFile ~/.ssh/mykeyfile
다음의 키 파일에 대한 설명 man ssh
:
-i identity_file
Selects a file from which the identity (private key) for RSA or
DSA authentication is read. The default is ~/.ssh/identity for
protocol version 1, and ~/.ssh/id_rsa and ~/.ssh/id_dsa for pro‐
tocol version 2. Identity files may also be specified on a per-
host basis in the configuration file. It is possible to have
multiple -i options (and multiple identities specified in config‐
uration files).
답변2
키 파일을 올바르게 설정하려면(방법여기), 다음 사항에 유의하세요.
.ssh
호스트 디렉터리와 파일에 올바른 권한이 없거나 원격 사용자 홈 디렉터리에 올바른 권한이 없는 경우 ssh는 키 파일을 찾았음에도 불구하고 계속 비밀번호를 묻습니다.
다음을 사용하여 키 파일/파일이 제공되는지 확인할 수 있습니다.ssh -vvv user@host
예제 출력:
debug1: Offering DSA public key: /Users/<user>/.ssh/id_dsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
원격 사용자 홈 디렉터리와 원격 .ssh
디렉터리 권한을 모두 확인하세요.
예를 들어 권한은 다음과 같아야 합니다.
$ls -ld .ssh
drwx------ 2 <owner> <group> 4096 2011-12-29 20:39 .ssh
$ls -ld ~/
drwxr-xr-x 28 <owner> <group> 4096 2011-12-29 20:15 /home/<user>/