我想缩短ssh尝试打开与主机的连接所需的时间。如果我输入例如ssh www.google.com
,直到提示返回需要很长时间。
我了解到可以使用ssh -o ConnectTimeout=10 www.google.com
,但即使是这样也需要很长时间。也许有一些尝试次数可以修改来减少阻塞时间吗?
我了解到可以改用 `ssh -o ConnectTimeout=10 www.google.com`,但即使是这样也需要很长时间。请问是否有一些尝试次数可以修改以减少阻塞时间?
我想缩短ssh尝试打开与主机的连接所需的时间。如果我输入例如ssh www.google.com
,直到提示返回需要很长时间。
我了解到可以使用ssh -o ConnectTimeout=10 www.google.com
,但即使是这样也需要很长时间。也许有一些尝试次数可以修改来减少阻塞时间吗?
问题可能是因为ssh正在尝试连接到www.google.com
解析到的所有不同IP地址。例如,在我的机器上:
# ssh -v -o ConnectTimeout=1 -o ConnectionAttempts=1 www.google.com
OpenSSH_5.9p1, OpenSSL 0.9.8t 18 Jan 2012
debug1: Connecting to www.google.com [173.194.43.20] port 22.
debug1: connect to address 173.194.43.20 port 22: Connection timed out
debug1: Connecting to www.google.com [173.194.43.19] port 22.
debug1: connect to address 173.194.43.19 port 22: Connection timed out
debug1: Connecting to www.google.com [173.194.43.18] port 22.
debug1: connect to address 173.194.43.18 port 22: Connection timed out
debug1: Connecting to www.google.com [173.194.43.17] port 22.
debug1: connect to address 173.194.43.17 port 22: Connection timed out
debug1: Connecting to www.google.com [173.194.43.16] port 22.
debug1: connect to address 173.194.43.16 port 22: Connection timed out
ssh: connect to host www.google.com port 22: Connection timed out
如果我使用特定的IP运行它,它会返回更快。
编辑:我已经用time
计时,结果如下: