the5fire

关注Python、Django、Vim、Linux、Web开发、团队管理和互联网--Life is short, we need Python.


解决SSH登录太慢的问题

作者:the5fire | 标签:       | 发布:2018-09-22 7:12 p.m. | 阅读量: 4289, 4134

简单小记

换了腾讯云国内的主机后,最近发现每次 SSH 上去都很艰难,一开始使用 fabric 自动部署博客上去还行,到后来直接超时。于是简单搜索了下,发现问题所在。

从搜索引擎上能得到的中文相关的博客就是两点:

  • 关闭 UseDNS —— UseDNS no
  • 关闭 GSSAPIAuthentication —— GSSAPIAuthentication no

从结果来看大家都是相互参考,很难确定是否解决了问题。对我来说这些方法没用,依然登录缓慢。探索中发现可能因为 btmp 文件过大导致。

见:https://serverfault.com/a/855071/292356

于是查了下关于 btmp 找到这个问题:

https://serverfault.com/questions/119299/my-var-log-btmp-file-is-huge-what-should-i-do, 摘部分答案:

This means people are trying to brute-force your passwords (common on any public-facing server).

It shouldn't cause any harm to clear out this file.

One way to reduce this is to change the port for SSH from 22 to something arbitrary. For some additional security, DenyHosts can block login attempts after a certain number of failures. I'd highly recommend installing and configuring it.

所以解决方案就是:

echo '' > /var/log/btmp

主机的安全性

通过看上面的答案能了解到,总是有人在尝试登陆你的主机。这个情况似乎比之前用的香港主机和国外主机要严重。

所以拿到新主机之后,很有必要对常用端口做一些调整,避免有人对你做暴力破解尝试。初始化的网络安全组策略也是需要关注的。

- from the5fire.com
----EOF-----

微信公众号:Python程序员杂谈


其他分类: