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链表操作方式

《Linux链表操作方式》:本文主要介绍Linux链表操作方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、链表基础概念与内核链表优势二、内核链表结构与宏解析三、内核链表的优点四、用户态链表示例五、双向循环链表在内核中的实现优势六、典型应用场景七、调试技巧与

详解Linux中常见环境变量的特点与设置

《详解Linux中常见环境变量的特点与设置》环境变量是操作系统和用户设置的一些动态键值对,为运行的程序提供配置信息,理解环境变量对于系统管理、软件开发都很重要,下面小编就为大家详细介绍一下吧... 目录前言一、环境变量的概念二、常见的环境变量三、环境变量特点及其相关指令3.1 环境变量的全局性3.2、环境变

Linux系统中的firewall-offline-cmd详解(收藏版)

《Linux系统中的firewall-offline-cmd详解(收藏版)》firewall-offline-cmd是firewalld的一个命令行工具,专门设计用于在没有运行firewalld服务的... 目录主要用途基本语法选项1. 状态管理2. 区域管理3. 服务管理4. 端口管理5. ICMP 阻断

Linux实现线程同步的多种方式汇总

《Linux实现线程同步的多种方式汇总》本文详细介绍了Linux下线程同步的多种方法,包括互斥锁、自旋锁、信号量以及它们的使用示例,通过这些同步机制,可以解决线程安全问题,防止资源竞争导致的错误,示例... 目录什么是线程同步?一、互斥锁(单人洗手间规则)适用场景:特点:二、条件变量(咖啡厅取餐系统)工作流

Golang 日志处理和正则处理的操作方法

《Golang日志处理和正则处理的操作方法》:本文主要介绍Golang日志处理和正则处理的操作方法,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考... 目录1、logx日志处理1.1、logx简介1.2、日志初始化与配置1.3、常用方法1.4、配合defer

springboot加载不到nacos配置中心的配置问题处理

《springboot加载不到nacos配置中心的配置问题处理》:本文主要介绍springboot加载不到nacos配置中心的配置问题处理,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑... 目录springboot加载不到nacos配置中心的配置两种可能Spring Boot 版本Nacos

Linux中修改Apache HTTP Server(httpd)默认端口的完整指南

《Linux中修改ApacheHTTPServer(httpd)默认端口的完整指南》ApacheHTTPServer(简称httpd)是Linux系统中最常用的Web服务器之一,本文将详细介绍如何... 目录一、修改 httpd 默认端口的步骤1. 查找 httpd 配置文件路径2. 编辑配置文件3. 保存

Linux使用scp进行远程目录文件复制的详细步骤和示例

《Linux使用scp进行远程目录文件复制的详细步骤和示例》在Linux系统中,scp(安全复制协议)是一个使用SSH(安全外壳协议)进行文件和目录安全传输的命令,它允许在远程主机之间复制文件和目录,... 目录1. 什么是scp?2. 语法3. 示例示例 1: 复制本地目录到远程主机示例 2: 复制远程主

Java中的登录技术保姆级详细教程

《Java中的登录技术保姆级详细教程》:本文主要介绍Java中登录技术保姆级详细教程的相关资料,在Java中我们可以使用各种技术和框架来实现这些功能,文中通过代码介绍的非常详细,需要的朋友可以参考... 目录1.登录思路2.登录标记1.会话技术2.会话跟踪1.Cookie技术2.Session技术3.令牌技

Linux基础命令@grep、wc、管道符的使用详解

《Linux基础命令@grep、wc、管道符的使用详解》:本文主要介绍Linux基础命令@grep、wc、管道符的使用,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐... 目录grep概念语法作用演示一演示二演示三,带选项 -nwc概念语法作用wc,不带选项-c,统计字节数-