在Centos 7中与sshd相关的进程太多

当我在我的Centos 7机器上运行ps aux命令时,我看到大约100个条目:

 root 19862 0.0 0.0 151692 8 ? Ss Oct09 0:00 sshd: unknown [priv] sshd 19864 0.0 0.0 105068 0 ? S Oct09 0:00 sshd: unknown [net] 

我想问问这是正常的,还是我的系统受到某种sshpowershell攻击?

谢谢!

是的,这是正常的。 sshd为当前正在尝试authentication的每个用户打开2个新进程。

是的,这很可能表示有人尝试向您的服务器进行身份validation,而这并不意味着这一点。 如果没有的话,可以看看你的/var/log/auth.log应该指向你的networking中有一个不推荐的cron脚本运行的服务器。

经验法则:如果你担心有人可能进入,那么问题不是人们试图进入! 相反,确保没有人会成功的暴力。

可以按顺序调整sshdconfiguration,并在某种程度上限制处理这些系统资源的花费。 但是,对于除了最薄的服务器之外的任何设备,这些默认设置都应该是可以的,但这其实并不是什么大问题

 # Disable unused authentication methods # !! ONLY DISABLE PASSWORDS IF ALL USERS LOGIN USING KEYS !! PasswordAuthentication no # If the above is true, also limit the time users have to present # their authentication # If theres no passwords typed, something <60 seconds is reasonable # !! DO NOT SET TOO LOW! USERS MAY STILL NEED TO UNLOCK THEIR KEY/CARD !! LoginGraceTime 120 # Limit how many times a user can attempt to authenticate # !! Users who initially try the wrong key or invalid method will # !! first need to configure their ssh client properly # !! else they will be locked out if this is too low! MaxAuthTries 6 # Limit the number of concurrently authenticating users # start not accepting some connections if there are already 10 clients # stop accepting any connections if there are already 100 clients # !! one may even argue leaving this high is helpful, because # !! an attacker needs more resources to prevent legitimate connections MaxStartups 10:30:100 

你也可以将你的SSH移动到另一个端口,这将大大限制尝试的人数。 build议这样做。 这不会提高安全性,而且会使事情更加复杂。

首先我同意@anx所说的。

几件事情要添加(我做的):

  • 为了方便起见,可以使用fail2banparsing日志文件并阻止powershell攻击。 这不会增加安全性,但会降低日志中的噪音。
  • 要增加安全性,请使用基于密钥的login。
    • 为了达到更高的水平,可以使用openpgp卡来存储密钥,这样它就不再是可以被盗的磁盘上的文件。 (卡签名请求,但不能从卡中获得密钥。)
  • 妥协不完全禁用基于密码的login是添加第二因素authentication。
    • 谷歌authenticator pam模块和Android应用程序可以安装。 可以通过login的方式进行设置,除了input密码外,还需要input手机(或其他基于硬件的计算器软件)生成的号码。 这是一个基于时间的标记,所以如果encryption检查成功,它将授予您login。
  • 基于密钥的login和第二因素authentication可以同时启用。

教程:如何在centos 7上安装fail2ban