가상 머신에서 SSH 연결 시 비밀번호 없는 개인 키에 대한 비밀번호 요청

가상 머신에서 SSH 연결 시 비밀번호 없는 개인 키에 대한 비밀번호 요청

특정 가상 머신에 로그인할 때 SSH를 통해 서버에 연결하는 데 몇 가지 문제가 있습니다.

내 로컬 PC에서는 다음 명령을 사용하여 서버에 로그인할 수 있습니다 ssh -i .ssh/[my private key] username@domain.

그런 다음 관련되지 않은 다른 서버(동일한 개인 키가 있음)에 SSH를 통해 연결하고 위 명령을 실행하면 해당 서버에 정상적으로 로그인됩니다.

그러나 관련되지 않은 서버(역시 동일한 개인 키 사용)의 특정 OpenStack VM에 SSH로 연결한 다음 해당 서버에 SSH로 연결하면 암호를 묻는 메시지가 표시되기 시작합니다. 그런데 키에 비밀번호가 설정되어 있지 않아서 부득이하게 "권한이 거부되었습니다(공개키)"라는 메시지가 뜹니다. 실수.

다시 확인하기 위해 가상 머신에서 개인 키를 제거하고 scp내 컴퓨터에서 개인 키를 다시 넣은 다음 동일한 명령을 시도했지만 여전히 비밀번호를 입력하라는 메시지가 표시됩니다.

다시 말해서:

  1. PC - SSH - Server1 = 잘 작동함
  2. PC - SSH - Server2 - SSH - Server1 = 잘 작동함
  3. PC - SSH - Server2 - SSH - 가상 머신 - SSH - Server1 = 비밀번호 필요

그 이유는 무엇입니까? 이것은 확실히 내가 사용하고 있는 올바른 개인 키이며 적절한 권한이 있습니다.

ssh -v -i .ssh/[my private key] username@domain편집 - 필요에 따라 출력

OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to xxx.xxx.xxx.xxx [xxx.xxx.xxx.xxx] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /.ssh/[my private key].ppk type -1
debug1: key_load_public: No such file or directory
debug1: identity file /.ssh/[my private key].ppk-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.4
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.4 pat OpenSSH* compat 0x04000000
debug1: Authenticating to xxx.xxx.xxx.xxx:22 as '[my username]'
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: kex: [email protected] need=64 dh_need=64
debug1: kex: [email protected] need=64 dh_need=64
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:ZiugTjR5fM0E3evOwHoePFKspDQChA0Ab6L0q88KP/g
debug1: Host 'xxx.xxx.xxx.xxx' is known and matches the ECDSA host key.
debug1: Found key in /home/centos/.ssh/known_hosts:2
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /.ssh/[my private key].ppk
Enter passphrase for key '/.ssh/[my private key].ppk':
Enter passphrase for key '/.ssh/[my private key].ppk':
Enter passphrase for key '/.ssh/[my private key].ppk':
debug1: No more authentication methods to try.
Permission denied (publickey).

답변1

Enter passphrase for key '/.ssh/[my private key].ppk':

"ppk"는 사용된 확장자입니다.퍼티키 생성 도구. 퍼티 도구를 사용하여 키 파일을 생성한 것 같습니다. 안타깝게도 OpenSSH ssh유틸리티는 PuTTY 키 파일 형식을 읽을 수 없습니다. ssh키 파일을 구문 분석할 수 없을 때마다 비밀번호를 요청하므로 비밀번호를 요청하세요.

퍼티 키 도구를 사용하여 OpenSSH 형식으로 키를 내보낼 수 있습니다. 두 개의 파일로 끝나야 하며 my-private-key..pub my-private-key.pub파일에는 원격 시스템에 설치된 공개 키 부분이 포함되어 있습니다. 다른 파일에는 이 명령에 사용하는 개인 키가 포함되어 있습니다 ssh.

또는 OpenSSH ssh-keygen유틸리티를 사용하여 새 키를 생성할 수 있습니다.

관련 정보