
그래서 저는 집에 있는 컴퓨터와 서버를 가지고 있습니다. 내 개인 키를 사용하여 내 서버에 로그인하려고 합니다.
serveruser
내 서버에는 다음을 사용하여 집 컴퓨터에서 로그인하는 사용자가 있다고 가정합니다.
ssh -Y [email protected]
그리고 내 집 컴퓨터에는 내 집 컴퓨터에 사용자가 있습니다 homeuser
.
이제 개인 키를 사용하여 서버에 로그인하고 싶습니다. 이를 위해 이미 /home/homeuser/.ssh/
. 그래서 공개 키(id_rsa.pub)를 가져와서 내 서버에 복사했습니다 /home/serveruser/.ssh/authorized_keys
.
이제 해당 키를 사용하여 로그인하고 싶기 때문에 다음을 사용하여 로그인을 시도했습니다.
ssh -Y [email protected]
그리고 여전히 암호가 아닌 암호를 묻습니다.
나는 또한 다음을 사용하여 로그인을 시도했습니다.
ssh -i /home/homeuser/.ssh/id_rsa -Y [email protected]
사용자 비밀번호를 묻는 메시지가 계속 표시됩니다.
내가 뭘 잘못했나요? 조언해주세요.
어떤 노력을 해주셔서 감사합니다.
편집: Mason Heller의 권장 사항에 따라 ssh-add를 실행했지만 여전히 비밀번호를 입력해야 한다고 주장합니다.[이메일 보호됨].
편집: ssh -v -Y myserver.com
(익명성을 위해 수정된 개인 정보)의 정보.
OpenSSH_5.9p1 Debian-5ubuntu1.1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to myserver.com [100.100.100.100] port 22.
debug1: Connection established.
debug1: identity file /home/homeuser/.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/homeuser/.ssh/id_rsa-cert type -1
debug1: identity file /home/homeuser/.ssh/id_dsa type -1
debug1: identity file /home/homeuser/.ssh/id_dsa-cert type -1
debug1: identity file /home/homeuser/.ssh/id_ecdsa type -1
debug1: identity file /home/homeuser/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.0p1 Debian-4
debug1: match: OpenSSH_6.0p1 Debian-4 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.1
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 b2:1a:68:21:5a:72:c4:f7:ec:ea:60:12:e4:f8:b5:71
debug1: Host 'myserver.com' is known and matches the ECDSA host key.
debug1: Found key in /home/homeuser/.ssh/known_hosts:11
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/homeuser/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: [email protected]
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/homeuser/.ssh/id_dsa
debug1: Trying private key: /home/homeuser/.ssh/id_ecdsa
debug1: Next authentication method: password
추가 정보:
고양이 /home/homeuser/.ssh/id_rsa.pub
--removed for security--
/home/serveruser/.ssh/authorized_keys
total 4
-rwx------ 1 serveruser serveruser 400 Jan 26 01:09 id_rsa.pub
고양이 /home/serveruser/.ssh/authorized_keys
cat: /home/serveruser/.ssh/authorized_keys: Is a directory
답변1
/home/serveruser/.ssh/authorized_keys
파일이어야 합니다.
id_rsa.pub의 내용을 추가하여 생성합니다(예: cat /home/homeuser/.ssh/id_rsa.pub >>authorized_keys).
(물론 먼저 공개 키를 서버에 복사해야 합니다.)
답변2
키 쌍을 사용하려면 ssh-agent를 실행하여 인증을 처리할 수 있습니다.
eval $(ssh-agent)
ssh-add
그러면 해당 터미널의 모든 후속 SSH 세션에서 키 쌍을 사용할 수 있습니다. 이를 사용하는 ssh-agent
데 필요한 터미널 세션에 환경 변수를 추가합니다 ssh
. 나는 일반적으로 ssh-agent > ~/.ssha; . ~/.ssha; ssh-add
하나의 pty에서 실행한 다음 source ~/.ssha
SSH를 사용해야 하는 다른 pty에서 실행하므로 모든 pty가 에이전트를 사용할 수 있습니다. 또한 공개 키를 서버에 추가하는 데
사용하는 것이 더 쉽다는 것을 알았습니다 . ssh-copy-id
그것은 당신의 삶도 더 쉽게 만들 수 있습니다. :)