我已经构建了一个运行在基于阿尔卑斯的容器中的SSH隧道服务,该服务基于这里概述的方法:https://github.com/cagataygurturk/docker-ssh-tunnel
该服务通过IdentityFiles连接,并设置多个ControlSockets和隧道。
我正在一个Amazon平台上测试这个问题,通过隧道进入一个PostgreSQL数据库。
SSH登录和隧道创建是正确的,隧道可以使用,但似乎有一个超时某处。
以下是证据:
Host my-bastion
HostName 99.99.99.99
User ec2-user
IdentityFile ~/.ssh/key.pem
Host *
ControlMaster auto
ControlPath ~/.ssh/controlmasters/cp_%r_%h
ControlPersist yes
StrictHostKeyChecking no
ServerAliveCountMax 60
ServerAliveInterval 30
TCPKeepAlive no
ForkAfterAuthentication yes
StdinNull yes
ExitOnForwardFailure yes
IPQoS 0x00以前使用ControlSocket建立的隧道。
使用验证失败的psql请求进行测试,但执行隧道操作。
在测试期间,psql通过隧道进行2次连接。
第一次访问后,至少5分钟空闲。
# date && time psql "host=localhost port=5430 dbname=xxx user=UUU password=X"
Tue Mar 8 12:10:57 PST 2022
psql: error: FATAL: password authentication failed for user "UUU"
FATAL: password authentication failed for user "UUU"
real 0m32.497s - slow!客户端日志-vv
1st psql request
[2022-03-08 20:10:57] debug1: Connection to port 5430 forwarding to xxx.us-east-1.rds.amazonaws.com port 5432 requested.
[2022-03-08 20:10:57] debug1: channel 3: new [direct-tcpip]
30 sec Delay here
[2022-03-08 20:10:57] debug2: channel 3: open confirm rwindow 2097152 rmax 32768
[2022-03-08 20:11:29] debug2: channel 3: read<=0 rfd 7 len 0
2nd psql request
[2022-03-08 20:11:29] debug1: Connection to port 5430 forwarding to xxx.us-east-1.rds.amazonaws.com port 5432 requested.
[2022-03-08 20:11:29] debug1: channel 4: new [direct-tcpip]
subsecond response on channel 4
[2022-03-08 20:11:29] debug2: channel 4: open confirm rwindow 2097152 rmax 32768
[2022-03-08 20:11:29] debug2: channel 4: read<=0 rfd 8 len 0第一次之后立即进入。
# date && time psql "host=localhost port=5430 dbname=xxx user=UUU password=X"
Tue Mar 8 12:11:41 PST 2022
psql: error: FATAL: password authentication failed for user "UUU"
FATAL: password authentication failed for user "UUU"
real 0m0.874s - fast!
user 0m0.021s
sys 0m0.016s
1st psql request
[2022-03-08 20:11:41] debug1: Connection to port 5430 forwarding to xxx.us-east-1.rds.amazonaws.com port 5432 requested.
[2022-03-08 20:11:41] debug2: fd 7 setting TCP_NODELAY
[2022-03-08 20:11:41] debug2: fd 7 setting O_NONBLOCK
[2022-03-08 20:11:41] debug1: channel 3: new [direct-tcpip]
Subsecond response to request
[2022-03-08 20:11:41] debug2: channel 3: open confirm rwindow 2097152 rmax 32768
[2022-03-08 20:11:42] debug2: channel 3: read<=0 rfd 7 len 0
...
2nd psql request
[2022-03-08 20:11:42] debug1: Connection to port 5430 forwarding to xxx.us-east-1.rds.amazonaws.com port 5432 requested.
[2022-03-08 20:11:42] debug1: channel 4: new [direct-tcpip]
[2022-03-08 20:11:42] debug2: channel 4: open confirm rwindow 2097152 rmax 32768我曾在这个问题上找过其他人,但没有发现有人在谈论这个问题。我尝试过来自https://jrs-s.net/2017/07/01/slow-ssh-logins/的建议,并将IpQos=0x00设置为解决任何潜在的路由器问题。
发布于 2022-03-16 12:09:04
问题在于我所使用的服务。Serverless的默认设置是在有5分钟不活动时暂停群集。当一个新连接出现时,服务需要30秒左右才能重新启动。
因此,5分钟后缓慢的连接是Serverless服务重新启动,根本不是SSH问题:-/
https://serverfault.com/questions/1095698
复制相似问题