최소 2명의 사용자(루트와 본인)가 있는 원격 서버가 있습니다. 두 $HOME 폴더의 .ssh/authorized_keys에 동일한 키가 있습니다. 루트 계정으로 연결할 수 있지만 내 계정에서 " Server refused our key
" 오류가 발생합니다. 오류가 있는지 확인하기 위해 sshd_config(서버의)와 .ssh 폴더를 확인했습니다. 두 계정 모두에 동일한 키 ed25519를 사용하고 있기 때문에 모르겠습니다. 내가 볼 수 있는 유일한 것은 UsePAM yes
/etc/ssh/sshd_config.d/50-redhat.conf이지만, 삭제하면 passwd를 사용하여 로그인할 수 없습니다.
이것은 ssh -v 결과입니다
[stan@DEL-3KC0G63 ~]$ ssh -v -i /mnt/c/Users/s.garret
/.ssh/id_ed25519 [email protected]
OpenSSH_8.0p1, OpenSSL 1.1.1k FIPS 25 Mar 2021
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
debug1: configuration requests final Match pass
debug1: re-parsing configuration
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
debug1: Connecting to 192.168.1.28 [192.168.1.28] port 22.
debug1: Connection established.
debug1: identity file /mnt/c/Users/s.garret/.ssh/id_ed25519 type 3
debug1: identity file /mnt/c/Users/s.garret/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.0
debug1: Remote protocol version 2.0, remote software version OpenSSH_9.0
debug1: match: OpenSSH_9.0 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.168.1.28:22 as 'stan'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
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: curve25519-sha256 need=32 dh_need=32
debug1: kex: curve25519-sha256 need=32 dh_need=32
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:LjRh07mgxeC37wDufL2WmbYVYTY0tKHptZSSZGc1Q3U
debug1: Host '192.168.1.28' is known and matches the ECDSA host key.
debug1: Found key in /home/stan/.ssh/known_hosts:3
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: /mnt/c/Users/s.garret/.ssh/id_ed25519 ED25519 SHA256:DF1VjlJzo51HzV0TQgCcKnRCZXlhr9rCwiJuZBZzVZU explicit
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected]>
debug1: kex_input_ext_info: [email protected] (unrecognised)
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available: Invalid UID in persistent keyring name
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available: Invalid UID in persistent keyring name
debug1: Next authentication method: publickey
debug1: Offering public key: /mnt/c/Users/s.garret/.ssh/id_ed25519 ED25519 SHA256:DF1VjlJzo51HzV0TQgCcKnRCZXlhr9rCwiJuZBZzVZU explicit
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Next authentication method: password
[email protected]'s password:
debug1: Authentication succeeded (password).
그리고 ssh 폴더에서 ls -la의 결과는 다음과 같습니다.
[stan@metal ~]$ ls -la .ssh/
total 24
drwx------. 2 stan stan 4096 17 juil. 18:20 .
drwxrwxr-x. 53 stan stan 4096 17 juil. 18:38 ..
-rw-------. 1 stan stan 115 4 juil. 08:34 authorized_keys
-rw-------. 1 stan stan 2622 16 févr. 2020 id_rsa
-rw-------. 1 stan stan 582 16 févr. 2020 id_rsa.pub
-rw-------. 1 stan stan 1361 16 mai 18:33 known_hosts
[stan@metal ~]$
답변1
SSH에는 보안을 위한 몇 가지 보안 제한 사항이 있습니다. ~/.ssh 아래의 모든 항목은 괜찮아 보이지만 .ssh 디렉터리 ls
출력 의 ..에 따르면 stan $HOME은 775/rwxrwxr-x에서 너무 개방적입니다.
stan으로 실행하는 경우:
chmod 700 $HOME
또는 루트인 경우:
chmod 700 ~stan
이제 SSH가 작동할 것입니다.