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中的计划任务(crontab)使用方式

《Linux中的计划任务(crontab)使用方式》:本文主要介绍Linux中的计划任务(crontab)使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、前言1、linux的起源与发展2、什么是计划任务(crontab)二、crontab基础1、cro

Linux换行符的使用方法详解

《Linux换行符的使用方法详解》本文介绍了Linux中常用的换行符LF及其在文件中的表示,展示了如何使用sed命令替换换行符,并列举了与换行符处理相关的Linux命令,通过代码讲解的非常详细,需要的... 目录简介检测文件中的换行符使用 cat -A 查看换行符使用 od -c 检查字符换行符格式转换将

Python FastAPI+Celery+RabbitMQ实现分布式图片水印处理系统

《PythonFastAPI+Celery+RabbitMQ实现分布式图片水印处理系统》这篇文章主要为大家详细介绍了PythonFastAPI如何结合Celery以及RabbitMQ实现简单的分布式... 实现思路FastAPI 服务器Celery 任务队列RabbitMQ 作为消息代理定时任务处理完整

Linux系统配置NAT网络模式的详细步骤(附图文)

《Linux系统配置NAT网络模式的详细步骤(附图文)》本文详细指导如何在VMware环境下配置NAT网络模式,包括设置主机和虚拟机的IP地址、网关,以及针对Linux和Windows系统的具体步骤,... 目录一、配置NAT网络模式二、设置虚拟机交换机网关2.1 打开虚拟机2.2 管理员授权2.3 设置子

Linux系统中卸载与安装JDK的详细教程

《Linux系统中卸载与安装JDK的详细教程》本文详细介绍了如何在Linux系统中通过Xshell和Xftp工具连接与传输文件,然后进行JDK的安装与卸载,安装步骤包括连接Linux、传输JDK安装包... 目录1、卸载1.1 linux删除自带的JDK1.2 Linux上卸载自己安装的JDK2、安装2.1

C#使用SQLite进行大数据量高效处理的代码示例

《C#使用SQLite进行大数据量高效处理的代码示例》在软件开发中,高效处理大数据量是一个常见且具有挑战性的任务,SQLite因其零配置、嵌入式、跨平台的特性,成为许多开发者的首选数据库,本文将深入探... 目录前言准备工作数据实体核心技术批量插入:从乌龟到猎豹的蜕变分页查询:加载百万数据异步处理:拒绝界面

Linux卸载自带jdk并安装新jdk版本的图文教程

《Linux卸载自带jdk并安装新jdk版本的图文教程》在Linux系统中,有时需要卸载预装的OpenJDK并安装特定版本的JDK,例如JDK1.8,所以本文给大家详细介绍了Linux卸载自带jdk并... 目录Ⅰ、卸载自带jdkⅡ、安装新版jdkⅠ、卸载自带jdk1、输入命令查看旧jdkrpm -qa

Springboot处理跨域的实现方式(附Demo)

《Springboot处理跨域的实现方式(附Demo)》:本文主要介绍Springboot处理跨域的实现方式(附Demo),具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不... 目录Springboot处理跨域的方式1. 基本知识2. @CrossOrigin3. 全局跨域设置4.

Linux samba共享慢的原因及解决方案

《Linuxsamba共享慢的原因及解决方案》:本文主要介绍Linuxsamba共享慢的原因及解决方案,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录linux samba共享慢原因及解决问题表现原因解决办法总结Linandroidux samba共享慢原因及解决

springboot security验证码的登录实例

《springbootsecurity验证码的登录实例》:本文主要介绍springbootsecurity验证码的登录实例,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,... 目录前言代码示例引入依赖定义验证码生成器定义获取验证码及认证接口测试获取验证码登录总结前言在spring