sshd:root@notty: linux 被暴力登录处理

2024-03-13 15:48

本文主要是介绍sshd:root@notty: linux 被暴力登录处理,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

一、背景

今天打开自己的私有服务器,猛然间发现最近登录失败将近2000次, 登录失败的ip 134.209.236.115 德国法兰克福。一顿吃鲸。。。。

由于我是私有服务器,在进行外网和内网ssh的端口映射时已经提前改为非22端口了,这算是第一道防线。密码设置也相对复杂,所以比较幸运的是,还好还未被攻破,赶紧处理一番

二、常规处理方案
1、修改公网的端口和内网端口映射为不常见的端口(一般ssh端口默认是22)。如果是阿里、腾讯云服务,则可以变更ssh端口为非22端口.同时配置安全策略组。

2、修改root 用户不可远程登录

3、限制ip登录(指定ip可进行远程登录访问服务器)

三、问题处理

1、问题查看

第一步,我之前已经做了,第三部,限制ip登录,对我来讲,由于可能会随时随地使用公司网络、家里的网络、手机公网、或者其他公共区域访问自己的私有服务,故而,限制ip,指定ip 这个方案,对我不太合适。所以接下来主要是针对 第二步进行处理。

在处理前,先查看登录失败的信息,输入命令,发现破解者使用了多种用户进行试登录

lastb  (等同于查看 /var/log/btmp 文件内容)

[root@localhost ~]# lastbroot     ssh:notty    61.238.103.153   Mon Aug  9 03:29 - 03:29  (00:00)
debianus ssh:notty    136.144.41.41    Mon Aug  9 02:48 - 02:48  (00:00)
debianus ssh:notty    136.144.41.41    Mon Aug  9 02:48 - 02:48  (00:00)
debianus ssh:notty    136.144.41.41    Mon Aug  9 02:48 - 02:48  (00:00)
debianus ssh:notty    136.144.41.41    Mon Aug  9 02:48 - 02:48  (00:00)
admin    ssh:notty    136.144.41.41    Mon Aug  9 02:44 - 02:44  (00:00)
admin    ssh:notty    136.144.41.41    Mon Aug  9 02:44 - 02:44  (00:00)
admin    ssh:notty    136.144.41.41    Mon Aug  9 02:44 - 02:44  (00:00)
admin    ssh:notty    136.144.41.41    Mon Aug  9 02:44 - 02:44  (00:00)
admin    ssh:notty    136.144.41.41    Mon Aug  9 02:41 - 02:41  (00:00)
admin    ssh:notty    136.144.41.41    Mon Aug  9 02:41 - 02:41  (00:00)
admin    ssh:notty    136.144.41.41    Mon Aug  9 02:41 - 02:41  (00:00)
admin    ssh:notty    136.144.41.41    Mon Aug  9 02:40 - 02:40  (00:00)
root     ssh:notty    97.90.87.195     Mon Aug  9 02:37 - 02:37  (00:00)
root     ssh:notty    97.90.87.195     Mon Aug  9 02:37 - 02:37  (00:00)
support  ssh:notty    97.90.87.195     Mon Aug  9 02:37 - 02:37  (00:00)
support  ssh:notty    97.90.87.195     Mon Aug  9 02:37 - 02:37  (00:00)
root     ssh:notty    97.90.87.195     Mon Aug  9 02:37 - 02:37  (00:00)
usuario  ssh:notty    97.90.87.195     Mon Aug  9 02:37 - 02:37  (00:00)
usuario  ssh:notty    97.90.87.195     Mon Aug  9 02:37 - 02:37  (00:00)
default  ssh:notty    97.90.87.195     Mon Aug  9 02:37 - 02:37  (00:00)
default  ssh:notty    97.90.87.195     Mon Aug  9 02:37 - 02:37  (00:00)
root     ssh:notty    97.90.87.195     Mon Aug  9 02:37 - 02:37  (00:00)
root     ssh:notty    97.90.87.195     Mon Aug  9 02:37 - 02:37  (00:00)
root     ssh:notty    97.90.87.195     Mon Aug  9 02:37 - 02:37  (00:00)
root     ssh:notty    97.90.87.195     Mon Aug  9 02:36 - 02:36  (00:00)
admin    ssh:notty    136.144.41.41    Mon Aug  9 02:36 - 02:36  (00:00)
admin    ssh:notty    136.144.41.41    Mon Aug  9 02:36 - 02:36  (00:00)
admin    ssh:notty    136.144.41.41    Mon Aug  9 02:36 - 02:36  (00:00)
admin    ssh:notty    136.144.41.41    Mon Aug  9 02:36 - 02:36  (00:00)
ethos    ssh:notty    136.144.41.41    Mon Aug  9 02:32 - 02:32  (00:00)
ethos    ssh:notty    136.144.41.41    Mon Aug  9 02:32 - 02:32  (00:00)
ethos    ssh:notty    136.144.41.41    Mon Aug  9 02:32 - 02:32  (00:00)
ethos    ssh:notty    136.144.41.41    Mon Aug  9 02:32 - 02:32  (00:00)
mos      ssh:notty    136.144.41.41    Mon Aug  9 02:29 - 02:29  (00:00)
mos      ssh:notty    136.144.41.41    Mon Aug  9 02:29 - 02:29  (00:00)
user     ssh:notty    136.144.41.41    Mon Aug  9 02:26 - 02:26  (00:00)
user     ssh:notty    136.144.41.41    Mon Aug  9 02:26 - 02:26  (00:00)
user     ssh:notty    136.144.41.41    Mon Aug  9 02:26 - 02:26  (00:00)
user     ssh:notty    136.144.41.41    Mon Aug  9 02:26 - 02:26  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
hadoop   ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
admin    ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
hadoop   ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
hadoop   ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
root     ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
hadoop   ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
admin    ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
hadoop   ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
hadoop   ssh:notty    119.8.236.111    Mon Aug  9 01:51 - 01:51  (00:00)
minersta ssh:notty    141.98.10.203    Mon Aug  9 00:15 - 00:15  (00:00)
minersta ssh:notty    141.98.10.203    Mon Aug  9 00:15 - 00:15  (00:00)

查看登录记录文件大小:


[root@localhost ~]# ll -h /var/log/btmp
-rw------- 1 root utmp 40M 8月  19 00:36 /var/log/btmp# 统计登录
lastb | awk '{ print $3}' | sort | uniq -c | sort -n

2、添加新用户,禁止root 用户远程登录

添加新用户 useradd  newusername

设置密码  passwd  newusername

编辑 vim /etc/sudoers 

在root ALL=(ALL) ALL 下面添加

newusername ALL=(ALL) ALL 或者newusername ALL=(ALL) NOPASSWD:ALL

3、禁止root用户远程登录

vim /etc/ssh/sshd_config

文件中,# PermitRootLogin yes 修改为

PermitRootLogin no

4、重启sshd 服务

低版本centos使用: service sshd restart

高版本centos使用: systemctl restart sshd.service

5、之后远程登录,可以使用 newusername 登录,然后通过

sudo su 切换为root 用户。

以上三种方案:可参看博文:

https://blog.csdn.net/gammey/article/details/80404375

这篇关于sshd:root@notty: linux 被暴力登录处理的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/805370

相关文章

Linux使用nload监控网络流量的方法

《Linux使用nload监控网络流量的方法》Linux中的nload命令是一个用于实时监控网络流量的工具,它提供了传入和传出流量的可视化表示,帮助用户一目了然地了解网络活动,本文给大家介绍了Linu... 目录简介安装示例用法基础用法指定网络接口限制显示特定流量类型指定刷新率设置流量速率的显示单位监控多个

ElasticSearch+Kibana通过Docker部署到Linux服务器中操作方法

《ElasticSearch+Kibana通过Docker部署到Linux服务器中操作方法》本文介绍了Elasticsearch的基本概念,包括文档和字段、索引和映射,还详细描述了如何通过Docker... 目录1、ElasticSearch概念2、ElasticSearch、Kibana和IK分词器部署

Linux流媒体服务器部署流程

《Linux流媒体服务器部署流程》文章详细介绍了流媒体服务器的部署步骤,包括更新系统、安装依赖组件、编译安装Nginx和RTMP模块、配置Nginx和FFmpeg,以及测试流媒体服务器的搭建... 目录流媒体服务器部署部署安装1.更新系统2.安装依赖组件3.解压4.编译安装(添加RTMP和openssl模块

linux下多个硬盘划分到同一挂载点问题

《linux下多个硬盘划分到同一挂载点问题》在Linux系统中,将多个硬盘划分到同一挂载点需要通过逻辑卷管理(LVM)来实现,首先,需要将物理存储设备(如硬盘分区)创建为物理卷,然后,将这些物理卷组成... 目录linux下多个硬盘划分到同一挂载点需要明确的几个概念硬盘插上默认的是非lvm总结Linux下多

linux进程D状态的解决思路分享

《linux进程D状态的解决思路分享》在Linux系统中,进程在内核模式下等待I/O完成时会进入不间断睡眠状态(D状态),这种状态下,进程无法通过普通方式被杀死,本文通过实验模拟了这种状态,并分析了如... 目录1. 问题描述2. 问题分析3. 实验模拟3.1 使用losetup创建一个卷作为pv的磁盘3.

使用C++将处理后的信号保存为PNG和TIFF格式

《使用C++将处理后的信号保存为PNG和TIFF格式》在信号处理领域,我们常常需要将处理结果以图像的形式保存下来,方便后续分析和展示,C++提供了多种库来处理图像数据,本文将介绍如何使用stb_ima... 目录1. PNG格式保存使用stb_imagephp_write库1.1 安装和包含库1.2 代码解

C#使用DeepSeek API实现自然语言处理,文本分类和情感分析

《C#使用DeepSeekAPI实现自然语言处理,文本分类和情感分析》在C#中使用DeepSeekAPI可以实现多种功能,例如自然语言处理、文本分类、情感分析等,本文主要为大家介绍了具体实现步骤,... 目录准备工作文本生成文本分类问答系统代码生成翻译功能文本摘要文本校对图像描述生成总结在C#中使用Deep

Linux环境变量&&进程地址空间详解

《Linux环境变量&&进程地址空间详解》本文介绍了Linux环境变量、命令行参数、进程地址空间以及Linux内核进程调度队列的相关知识,环境变量是系统运行环境的参数,命令行参数用于传递给程序的参数,... 目录一、初步认识环境变量1.1常见的环境变量1.2环境变量的基本概念二、命令行参数2.1通过命令编程

Linux之进程状态&&进程优先级详解

《Linux之进程状态&&进程优先级详解》文章介绍了操作系统中进程的状态,包括运行状态、阻塞状态和挂起状态,并详细解释了Linux下进程的具体状态及其管理,此外,文章还讨论了进程的优先级、查看和修改进... 目录一、操作系统的进程状态1.1运行状态1.2阻塞状态1.3挂起二、linux下具体的状态三、进程的

Linux编译器--gcc/g++使用方式

《Linux编译器--gcc/g++使用方式》文章主要介绍了C/C++程序的编译过程,包括预编译、编译、汇编和链接四个阶段,并详细解释了每个阶段的作用和具体操作,同时,还介绍了调试和发布版本的概念... 目录一、预编译指令1.1预处理功能1.2指令1.3问题扩展二、编译(生成汇编)三、汇编(生成二进制机器语