linux – 为什么TLS握手在VPS上*永远*(20秒)?

我有一台服务器通常可以正常工作,但在尝试连接SSL时会卡住20秒(SSH或HTTPS显示相同的模式.)

我尝试了没有SSL的各种连接,例如telnet:

telnet server-name 80

输入GET命令

GET http://server-name/
Host: server-name
Accept: text/html,*/*
Accept-Language: en-us
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)

答案是100%即时的.

但是,当我尝试在浏览器中通过HTTPS连接到服务器,或者使用SSH连接到同一台服务器时,它会在连接前停留约20秒.

对于SSH,它将很好地工作(即不再慢).对于HTTPS,每次必须再次连接时,它会很慢.但是,未关闭的连接将继续快速运行.

我正在添加Firebug中出现的网络信息的屏幕截图.我们可以看到,每次尝试新连接时,都是20秒.通过htop查看服务器使用情况,cpu为0%,当发生某些事情时,它会在1分钟内达到0.01%的百分比.使用报告.因此整个服务器没有被任何方式挂钩(即,此时它是一个测试服务器,我们还没有被其他人点击.)

所以我的问题是:什么可能导致这种放缓?

我想也许OpenSSL可能会尝试使用/ dev / random,但我以前从未听说过这样的问题.随机设备在该VPS上根本不输出太多.但是,/ dev / urandom非常有效.我可以在几秒钟内获得1Mb的随机数据.我可以通过什么来解决这个问题呢?

/etc/resolv.conf看起来像Google DNS.应该快……

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8
nameserver 8.8.4.4

请注意,Apache2设置本身应该没有关系,因为它也发生在SSH …

我也试过ssh -vvv.连接是即时的.

OpenSSH_6.6.1,OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /home/alexis/.ssh/config
debug1: /home/alexis/.ssh/config line 202: Applying options for do-nia2match
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Hostname has changed; re-reading configuration
debug1: Reading configuration data /home/alexis/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to 178.62.213.172 [178.62.213.172] port 22.
debug1: Connection established.
...
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/alexis/.ssh/do-nia2match_rsa,explicit

SUPER LONG PAUSE HAPPENS HERE (~20s)

debug1: Authentications that can continue: publickey,password
debug3: start over,passed a different list publickey,password
debug3: preferred publickey,keyboard-interactive
debug3: authmethod_lookup publickey
...

我不太清楚为什么在发送密钥时SSH服务器会挂20秒…

解决方法

我发现(回来看评论)我阻止了除127.0.0.1地址之外的所有127.0.0.0.

Debian和Ubuntu使用您的域名在127.0.1.1的/ etc / hosts中定义了一个条目.您应该在/ etc / hosts文件的开头看到类似的内容

127.0.1.1     hostname.example.com hostname

我不得不检查我的防火墙,实际上我决定打开所有的127.x.x.x,因为它们都是私有网络的一部分,这些都是安全的IP.

相关文章

1、安装Apache。 1)执行如下命令,安装Apache服务及其扩展包...
一、先说一下用ansible批量采集机器信息的实现办法: 1、先把...
安装配置 1. 安装vsftpd 检查是否安装了vsftpd # rpm -qa | ...
如何抑制stable_secret读取关键的“net.ipv6.conf.all.stabl...
1 删除0字节文件 find -type f -size 0 -exec rm -rf {} ...
## 步骤 1:安装必要的软件包 首先,需要确保系统已安装 `dh...