
아야. 월요일이다.
PHP가 cron이 홈 폴더에 쓰는 일부 파일에 액세스할 수 있도록 다음 명령을 실행했습니다.
chown ec2-user:apache /home/ec2-user
chmod 2775 /home/ec2-user
# the owner of /home/ec2-user used to be root:root. I intended to change to root:apache, but copy/pasted this line from somewhere and didn't proofread.
연결이 종료될 때까지 문제가 계속 발생했으며 이제 더 이상 서버에 SSH로 접속할 수 없습니다. 오류는Permission denied (publickey,gssapi-keyex,gssapi-with-mic)
서버에 다시 액세스할 수 있는 아이디어가 있습니까?
이는 AWS의 Amazon Linux 2 인스턴스입니다.
답변1
제가 해결한 방법은 다음과 같습니다(@MisterSmith의 시스템 관리자 의견 덕분에).
"AWS System Manager" > 자동화로 이동하세요.
검색해서
AWSSupport-TroubleshootSSH
선택하세요.인스턴스를 선택합니다("관리형 인스턴스 표시" 선택을 "모든 인스턴스 표시"로 변경해야 함).
작업을 "모두 확인"으로 변경하고 오프라인 허용을 "True"로 변경한 다음 실행합니다.
(인스턴스의 중지/시작이 실행의 일부로 수행되었습니다.)
결과 출력:
----------[Diagnostic Results]----------
module run/openssh [SUCCESS] All configuration checks passed or all detected problems fixed.
-- FIXED Permission mode includes write for groups and/or other users: /home/ec2-user
-- FIXED Missing authorized key directory: /home/ssm-user/.ssh
-- FIXED Missing authorized key file: /home/ssm-user/.ssh/authorized_keys
-- FIXED Permission mode includes permissions for groups and/or other users: /etc/ssh/ssh_host_rsa_key
-- FIXED Permission mode includes permissions for groups and/or other users: /etc/ssh/ssh_host_ecdsa_key
-- FIXED Permission mode includes permissions for groups and/or other users: /etc/ssh/ssh_host_ed25519_key
SSH 액세스를 테스트했는데 모든 것이 이전처럼 작동합니다!
신기하게도 홈폴더는소유자변함이 없었습니다. 위 출력의 다른 부분에서 문제가 해결되었습니다.
ls -hal of /home/ec2-user in broken state:
drwxrwsr-x 7 ec2-user apache 4.0K May 18 06:59
ls -hal in repaired state:
drwxr-sr-x 7 ec2-user apache 4.0K May 18 06:59