나가는 모든 SSH 트래픽을 차단합니다.

나가는 모든 SSH 트래픽을 차단합니다.

내 EC2 인스턴스에서 의심스러운 활동이 발생했다고 보고되었으며 다음 이메일을 받았습니다.

보안 취약점을 찾기 위해 인터넷의 원격 호스트를 검색하는 것과 유사한 활동에 연루되었습니다. 이러한 성격의 활동은 AWS 이용 제한 정책(https://aws.amazon.com/aup/). 귀하의 검토를 위해 아래에 원본 보고서를 포함시켰습니다.

보고된 활동을 중지하는 조치를 취하고 취한 시정 조치에 대한 세부정보를 포함하여 이 이메일에 직접 회신해 주시기 바랍니다. 이러한 보고서에 설명된 활동이 악의적인 것으로 간주되지 않는 경우 사용 사례에 대한 세부정보를 포함하여 이 이메일에 회신해 주시기 바랍니다.

이러한 활동을 인식하지 못한다면 외부 공격자에 의해 환경이 손상되었거나 취약점으로 인해 시스템이 의도하지 않은 방식으로 사용되는 것일 수 있습니다.

무슨 일이 일어났는지 어떻게 확인하는지 모르겠어요. 루트 비밀번호를 변경했지만 여전히 동일한 활동 보고서가 표시됩니다.

아래는 로그입니다:

Full logs:
(time in UTC)=2020-12-08T23:59:13 (attacker's IP)=myip (IP being scanned)=91^208^184^50 (TCP port being scanned)=523
(time in UTC)=2020-12-08T23:59:21 (attacker's IP)=myip (IP being scanned)=78^128^99^30 (TCP port being scanned)=2025
(time in UTC)=2020-12-08T23:59:28 (attacker's IP)=myip (IP being scanned)=140^238^172^100 (TCP port being scanned)=841
(time in UTC)=2020-12-08T23:59:42 (attacker's IP)=myip (IP being scanned)=219^91^85^19 (TCP port being scanned)=10699
(time in UTC)=2020-12-08T23:59:54 (attacker's IP)=myip (IP being scanned)=78^128^99^30 (TCP port being scanned)=1298
(time in UTC)=2020-12-09T23:57:40 (attacker's IP)=myip (IP being scanned)=219^91^85^19 (TCP port being scanned)=313
(time in UTC)=2020-12-09T23:57:43 (attacker's IP)=myip (IP being scanned)=219^91^62^21 (TCP port being scanned)=21735
(time in UTC)=2020-12-09T23:57:43 (attacker's IP)=myip (IP being scanned)=91^203^192^19 (TCP port being scanned)=984
(time in UTC)=2020-12-09T23:57:52 (attacker's IP)=myip (IP being scanned)=185^178^44^132 (TCP port being scanned)=18263
(time in UTC)=2020-12-09T23:57:53 (attacker's IP)=myip (IP being scanned)=140^238^172^100 (TCP port being scanned)=1389

다른 로그:

Logs:
------------------------------------------------------------------------
Dec 9 01:01:55 kmh-wmh-003-nbg03 sshd[698]: Invalid user test from myip port 44682
Dec 9 01:01:55 kmh-wmh-003-nbg03 sshd[698]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=myip
Dec 9 01:01:57 kmh-wmh-003-nbg03 sshd[698]: Failed password for invalid user test from myip port 44682 ssh2
Dec 9 01:01:57 kmh-wmh-003-nbg03 sshd[698]: Received disconnect from myip port 44682:11: Bye Bye [preauth]
Dec 9 01:01:57 kmh-wmh-003-nbg03 sshd[698]: Disconnected from myip port 44682 [preauth]
Dec 9 01:18:16 kmh-wmh-003-nbg03 sshd[2480]: Invalid user pppuser from myip port 41660
Dec 9 01:18:16 kmh-wmh-003-nbg03 sshd[2480]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=myip
Dec 9 01:18:17 kmh-wmh-003-nbg03 sshd[2480]: Failed password for invalid user pppuser from myip port 41660 ssh2
Dec 9 01:18:17 kmh-wmh-003-nbg03 sshd[2480]: Received disconnect from myip port 41660:11: Bye Bye [preauth]
Dec 9 01:18:17 kmh-wmh-003-nbg03 sshd[2480]: Disconnected from myip port 41660 [preauth]
Dec 9 01:21:25 kmh-wmh-003-nbg03 sshd[2792]: Invalid user master from myip port 38852
Dec 9 01:21:25 kmh-wmh-003-nbg03 sshd[2792]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=myip

저는 인스턴스를 사용하여 SSH에 연결하지 않기 때문에 모든 사용자 및 앱/프로세스에서 나가는 모든 SSH 트래픽을 차단하고 싶습니다. 그렇게하는 방법?

어쩌면 iptables를 사용하여 포트 22로 나가는 모든 트래픽을 차단할 수 있지만 포트 22를 사용하는 모든 SSH는 그렇지 않습니까? 다른 효과적인 방법은 없나요?

답변1

그렇게 쉬운 일이 아닙니다. 서버가 손상되면 조사해야 합니다.

먼저 들어오는 모든 트래픽을 차단하되 서비스(예: 포트 80 및 443)는 모든 소스에서 SSH에 대한 액세스를 차단합니다.

둘째, clamav, chkrootkit 및 rkhunter와 같은 소프트웨어를 설치하고 실행하는 것이 좋습니다. 이러한 소프트웨어는 컴퓨터를 검사하고 잘 알려진 여러 악용 사례를 식별할 수 있습니다.

셋째, 실행 중인 모든 프로세스, 로그 등을 살펴봅니다.

넷째, 기계에 몇 가지 강화 기술을 적용하십시오.

답변2

포트 22/SSH 서비스에 대한 인바운드 규칙이 있는 경우 "보안 그룹"을 확인하여 이를 제거하세요.

SSH를 전혀 사용하지 않는다면 어떤 서비스를 실행하고 있습니까?

관련 정보