SSH 키를 생성하고 여전히 비밀번호를 요청합니다.

SSH 키를 생성하고 여전히 비밀번호를 요청합니다.

Windows R2012 서버에서 OpenSSH를 사용하여 비밀번호 없이 Linux 서버에 연결하려고 합니다. 지금까지 수행한 작업은 다음과 같습니다. run ssh-keygen -t rsacopy id_rsa.pubto the linux server. 그런 다음 달렸 ssh username@hostname지만 여전히 비밀번호를 묻습니다. 디버그 메시지는 다음과 같습니다.

ssh  tsdev@hostname -v
OpenSSH_for_Windows_8.0p1, LibreSSL 2.6.5
debug1: Connecting to hostname  [hostname ] port 22.
debug1: Connection established.
debug1: identity file C:\\Users\\UserName/.ssh/id_rsa type 0
debug1: identity file C:\\Users\\UserName/.ssh/id_rsa-cert type -1
debug1: identity file C:\\Users\\UserName/.ssh/id_dsa type -1
debug1: identity file C:\\Users\\UserName/.ssh/id_dsa-cert type -1
debug1: identity file C:\\Users\\UserName/.ssh/id_ecdsa type -1
debug1: identity file C:\\Users\\UserName/.ssh/id_ecdsa-cert type -1
debug1: identity file C:\\Users\\UserName/.ssh/id_ed25519 type -1
debug1: identity file C:\\Users\\UserName/.ssh/id_ed25519-cert type -1
debug1: identity file C:\\Users\\UserName/.ssh/id_xmss type -1
debug1: identity file C:\\Users\\UserName/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.0
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000002
debug1: Authenticating to hostname :22 as 'tsdev'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: [email protected] compress
ion: none
debug1: kex: client->server cipher: aes128-ctr MAC: [email protected] compress
ion: none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<3072<8192) sent
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-rsa SHA256:iPIV2C3o7iAWctj17etTxHdcbPLJjLvWR5pbhQyJ
VsU
debug1: Host 'hostname ' is known and matches the RSA host key.
debug1: Found key in C:\\Users\\UserName/.ssh/known_hosts:2
debug1: rekey out after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 4294967296 blocks
debug1: Will attempt key: C:\\Users\\UserName\\.ssh\\id_rsa RSA SHA256:+6FE/fz08
CxtJQkbSzk4pm2xcJc/bsa2txF7ng2u3RQ agent
debug1: Will attempt key: C:\\Users\\UserName/.ssh/id_rsa RSA SHA256:cxtm55sHmeJ
H2dPeTBY3VSnV9BuL58xMT94nTpn5PtE
debug1: Will attempt key: C:\\Users\\UserName/.ssh/id_dsa
debug1: Will attempt key: C:\\Users\\UserName/.ssh/id_ecdsa
debug1: Will attempt key: C:\\Users\\UserName/.ssh/id_ed25519
debug1: Will attempt key: C:\\Users\\UserName/.ssh/id_xmss
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mi
c,password
debug1: Next authentication method: publickey
debug1: Offering public key: C:\\Users\\UserName\\.ssh\\id_rsa RSA SHA256:+6FE/f
z08CxtJQkbSzk4pm2xcJc/bsa2txF7ng2u3RQ agent
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mi
c,password
debug1: Offering public key: C:\\Users\\UserName/.ssh/id_rsa RSA SHA256:cxtm55sH
meJH2dPeTBY3VSnV9BuL58xMT94nTpn5PtE
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mi
c,password
debug1: Trying private key: C:\\Users\\UserName/.ssh/id_dsa
debug1: Trying private key: C:\\Users\\UserName/.ssh/id_ecdsa
debug1: Trying private key: C:\\Users\\UserName/.ssh/id_ed25519
debug1: Trying private key: C:\\Users\\UserName/.ssh/id_xmss
debug1: Next authentication method: password
debug1: read_passphrase: can't open /dev/tty: No such file or directory

누구든지 어떤 제안을 할 수 있습니까? 감사해요!

답변1

귀하의 클라이언트(Windows Box)가 실제로 개인 키를 필요한 대로 사용하려고 시도하고 있으며 서버가 이를 전혀 받아들이지 않는 것 같습니다. 따라서 문제는 (Linux) 서버 측에서 발생할 가능성이 높습니다.

귀하의 질문에서 "id_rsa.pub를 서버에 복사"한 것이 정확히 무엇인지 명확하지 않습니다. 하지만 명시적으로 언급하지 않았기 때문에 옳은 일을 하고 있지 않을 수도 있다고 생각합니다.

~/.ssh/authorized_keys서버가 기본 구성으로 OpenSSH를 사용한다고 가정하면 where ~is your home 디렉터리 라는 파일에 공개 키를 넣어야 합니다 . 공개 키만 원하는 경우 파일 이름을 바꿀 수 있습니다. 그렇지 않으면 내용을 파일 id_rsa.pub에 복사할 수 있습니다 authorized_keys.

cat id_rsa.pub >> ~/.ssh/authorized_keys

파일의 보안을 확인할 수도 있습니다. "그룹" 및 기타 읽기 권한을 가질 수 없습니다. 다음과 같은 방법으로 권한을 설정할 수 있습니다.

# Either set numbered permissions: read write for user, nothing for group other
chmod 600 ~/.ssh/authorized_keys

# or remove Read Write eXecute permissions from Group and Other
chmod go-rwx ~/.ssh/authorized_keys

관련 정보