当前位置:网站首页>6-6漏洞利用-SSH安全防御
6-6漏洞利用-SSH安全防御
2022-07-06 18:46:00 【山兔1】

SSH修改默认端口
默认情况下,SSH使用22端口。为了安全,一般情况下都会修改默认端口。

修改22为其它的端口号,从而修改了我们的监听端口
注意:修改之后必须重新启动SSH服务,这样才能使得我们的配置文件,在重启的过程中,重新加载,从而生效。
开启ubuntu的ssh服务功能,在kali当中进行探测
nc 192.168.0.104 22

在ubuntu当中,修改端口号
cd /etc/ssh/
ls
sudo gedit sshd_config
2222
service ssh restart
service ssh status


netstat -pantu

nc 192.168.0.104 22
nc 192,168.0.104 2222

修改默认端口的作用,使得我们不可以直接使用22号端口连接,需要进一步探测,探测出ssh监听的端口,才能进行对应的连接
SSH设置PGP登录
默认情况下,SSH使用用户名和密码进行远程登录这个过程,会造成暴力破解,不断尝试用户名和密码,从而登录到系统中,为了防止这一过程的出现,通过putty这个软件,来生成对应的私钥,对私钥进行配置,进行身份验证,使得我们不经过用户密码进行登录,更加安全,防止暴力破解
生成SSH密钥对,使用puttygen。
下载链接:https://www.chiark.greenend.org/~sgtatham/putty/latest.html
点击Generate进行生成私钥

点击save private key,就会在桌面生成.ppk,这个名字也可以自己命名
SSH设置PGP登录
使用ssh-keygen命令在Linux生成.ssh目录,在.ssh下新建密钥存储文件authorized_keys,并复制私钥文件到.ssh目录下。使用命令puttygen -L “拷贝私钥文件”,将内容拷贝到authorized_keys文件中。
ssh-keygen

这个时候就会在/home/liuxiaoyang/下生成隐藏目录.ssh,切换到.ssh,新建目录authorized_keys

SSH设置PGP登录
使用Putty客户端加载私钥文件进行连接。
点击auth

加载之后,我们在连接中,就不需要输入对应的连接密码,只需要在Data中输入用户名

cd ~
pwd
ls -alh

cd .ssh/
ls
puttygen -L private.ppk

gedit authorized_keys

将内容粘添到这里,进行保存,保存完之后,我们就拥有了一个aythorized_keys文件
这个时候,我们就可以在windows下,或者其它系统下安装ppy,在客户端软件下,连接ssh,使用的是PGP连接
SSH防御暴力破解用户账号
设置pgp是为了防止暴力破解,但我们依然可以使用账号密码登录
在linux下可以配置不能使用用户名和密码登录,只使用SSH PGP方式验证登录。规避了SSH暴力破解。

出现问题:不能使用用户密码登录,很大程度上存在复杂操作。
比如说,我们当前系统有很多管理员,不能使用用户名密码登录后,每个人都需要PPT文件,才能进行登录,会是很大的工作和操作
cd /etc/ssh/
sudo gedit sshd_config
service ssh restart
service ssh status


下面,我们在kali当中使用用户名密码登录,来进行验证
ssh [email protected]
ssh [email protected] -p 2222

因为我们本身就不能登录,所以暴力破解的软件,就失效了
iptables设置阈值防止暴力破解
用iptables防火墙来防止暴力破解,我们可以设置对应的阈值,我们尝试登录三次之后,就锁定登录,使得他无法登录
利用Iptables对多次连接验证错误,进行账户锁定120秒。
sudo iptables -l INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --set
sudo iptables -l INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --update --seconds 120 --hitcount 3 -j DROP
在设置完之后,需要重新启动SSH服务。
service ssh restart

我们可以设置更长的时间,一天只能尝试三个组合,一年只能尝试一千个组合,我们密码设置复杂的情况下,暴力破解也是一个很慢的情况,暴力破解就无法生效,或者说,耗费的精力比较大,几十年,可能是几万年,才能将目前的字典,猜解完
边栏推荐
- 低代码平台中的数据连接方式(上)
- FLIR blackfly s industrial camera: synchronous shooting of multiple cameras through external trigger
- Untiy文本框的代码换行问题
- Introduction to the internal structure of the data directory of PostgreSQL
- Station B's June ranking list - feigua data up main growth ranking list (BiliBili platform) is released!
- 机器人队伍学习方法,实现8.8倍的人力回报
- 【LeetCode】Day97-移除链表元素
- argo workflows源码解析
- 纽约大学 CITIES 研究中心招聘理学硕士和博士后
- ODBC database connection of MFC windows programming [147] (with source code)
猜你喜欢

FLIR blackfly s usb3 industrial camera: white balance setting method

Blackfly s usb3 industrial camera: buffer processing
![leetcode:736. LISP syntax parsing [flowery + stack + status enumaotu + slots]](/img/0d/e07fe970167368040eb09b05c3682e.png)
leetcode:736. LISP syntax parsing [flowery + stack + status enumaotu + slots]

How can reinforcement learning be used in medical imaging? A review of Emory University's latest "reinforcement learning medical image analysis", which expounds the latest RL medical image analysis co

FLIR blackfly s usb3 industrial camera: how to use counters and timers

TiFlash 源码阅读(四)TiFlash DDL 模块设计及实现分析

如何从0到1构建32Core树莓派集群

本周 火火火火 的开源项目!

新一代云原生消息队列(一)

This week's hot open source project!
随机推荐
FLIR blackfly s industrial camera: synchronous shooting of multiple cameras through external trigger
The mega version model of dall-e MINI has been released and is open for download
阿里云中间件开源往事
[paper reading | deep reading] anrl: attributed network representation learning via deep neural networks
遇到慢SQL该怎么办?(下)
【论文阅读|深读】RolNE: Improving the Quality of Network Embedding with Structural Role Proximity
Recent applet development records
AWS学习笔记(一)
投资的再思考
Yyds dry goods inventory # solve the real problem of famous enterprises: maximum difference
【论文阅读|深读】 GraphSAGE:Inductive Representation Learning on Large Graphs
Metaforce force meta universe development and construction - fossage 2.0 system development
低代码平台中的数据连接方式(上)
Halcon实例转OpenCvSharp(C# OpenCV)实现--瓶口缺陷检测(附源码)
unity 自定义webgl打包模板
B站6月榜单丨飞瓜数据UP主成长排行榜(哔哩哔哩平台)发布!
[server data recovery] data recovery case of a Dell server crash caused by raid damage
老板被隔离了
Apifox,你的API接口文档卷成这样了吗?
#yyds干货盘点# 解决名企真题:最大差值