SSH 비밀번호 없는 로그인은 두 번째 상자에 대한 서비스 계정을 제외하고 대부분 작동합니다.

SSH 비밀번호 없는 로그인은 두 번째 상자에 대한 서비스 계정을 제외하고 대부분 작동합니다.

나는 몇 달 전에 작은 Linux 상자를 설정했고 개인 사용자 ID와 서비스 계정 ID 모두에 대해 비밀번호 없는 SSH 로그인을 설정했습니다. 둘 다 잘 작동합니다. 서비스 계정의 개인/공개 키 파일을 클라이언트 상자의 개인 사용자 ID에 대한 키를 저장한 동일한 위치에 저장했습니다.

기본 가이드로 다음을 사용하고 있습니다.http://www.tecmint.com/ssh-passwordless-login-using-ssh-keygen-in-5-easy-steps/.

오늘 나는 같은 방식으로 구성하려고 두 번째 상자를 설정했습니다. 개인 사용자 ID로 작동시키는 데 아무런 문제가 없었습니다. 하지만 서비스 계정에서는 여전히 작동하지 않는데 이유를 모르겠습니다. 두 번째 상자에 서비스 계정을 사용하여 SSH를 시도하면 비밀번호를 묻는 메시지가 표시된 다음 로그인할 수 있습니다.

두 상자 모두 ~/.ssh/authorized_keys 파일에 서비스 계정의 공개 키가 삽입되어 있고, 두 상자의 키 값이 동일한 것을 확인했습니다.

~/.ssh의 권한은 700이고, ~/.ssh/authorized_keys의 권한은 600임을 확인했습니다(640으로도 테스트했는데 권장 값으로 읽었습니다). 서비스 계정의 홈 디렉터리에 있는 두 상자 모두에서 이를 확인했습니다.

서비스 계정의 숫자 사용자 ID는 두 상자에서 서로 다릅니다. 나는 그것이 어떤 차이를 가져올 것이라고 생각하지 않습니다.

또한 서비스 계정을 사용하여 두 상자 중 하나로 ssh를 보낸 후 서비스 계정을 사용하여 해당 상자에서 다른 상자로 ssh를 시도하면 암호를 묻는 메시지가 표시됩니다.

"known_hosts"로 뭔가를 해야 합니까, 아니면 다른 일을 해야 합니까?

업데이트:

조언대로 "-v"를 사용하여 ssh를 실행하고 ssh 시도의 출력을 검사해 보았습니다.

다음은 일부 생략된 결과입니다.

%  ssh -v [email protected]
OpenSSH_7.2p2, OpenSSL 1.0.2h  3 May 2016
debug1: Reading configuration data /home/myuserid/.ssh/config
debug1: /home/myuserid/.ssh/config line 2: Applying options for *
debug1: Connecting to targethost.com [...] port 22.
debug1: Connection established.
debug1: identity file /home/myuserid/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/myuserid/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/myuserid/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/myuserid/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/myuserid/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/myuserid/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/myuserid/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/myuserid/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000
debug1: Authenticating to targethost.com:22 as 'serviceaccountid'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: [email protected]
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:...
debug1: Host 'targethost.com' is known and matches the ECDSA host key.
debug1: Found key in /home/myuserid/.ssh/known_hosts:18
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/myuserid/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /home/myuserid/.ssh/id_dsa
debug1: Trying private key: /home/myuserid/.ssh/id_ecdsa
debug1: Trying private key: /home/myuserid/.ssh/id_ed25519
debug1: Next authentication method: password
[email protected]'s password:

"다음 인증 방법: 공개 키" 뒤의 마지막 몇 줄에서 파일 경로 참조가 "/home/serviceaccountid"가 아닌 "/home/myuserid"라는 점이 궁금합니다. 그것은 큰 단서인 것 같습니다.

답변1

내 계정으로 댓글을 추가할 수는 없지만 문제 해결을 돕기 위해 더 많은 정보를 얻으려고 노력 중입니다.

로컬 컴퓨터 1대, 원격 컴퓨터 2대 등 세 대의 컴퓨터가 있는 것 같습니다. 그리고 그들 각각은 당신이 작업하는 두 개의 계정을 가지고 있습니까?

로컬 컴퓨터에 개인 및 서비스 계정이 있고 ssh service@remote-2로컬 컴퓨터의 개인 계정에서 실행하는 경우 서비스 계정이 아닌 로컬 개인 계정에 대한 SSH 키만 찾습니다. 원격 서비스 계정의 인증된 키 파일에 로컬-개인 공개 키를 추가했습니다.

"다음 인증 방법: 공개 키" 뒤의 마지막 몇 줄에서 파일 경로 참조가 "/home/serviceaccountid"가 아닌 "/home/myuserid"라는 점이 궁금합니다. 그것은 큰 단서인 것 같습니다.

그것은 로컬 계정에서 키를 찾는 ssh입니다. ssh를 호출하는 계정의 홈 디렉토리여야 합니다. 해당 경로가 서비스 계정의 홈이 될 것으로 예상되면 서비스 계정에 로그인하고그 다음에SSH를 실행하세요.

관련 정보