envredhat5
ssh远程链接服务器,经常会超时的解决办法
[oracle@hadoop~]$Readfromremotehost121.248.200.15:Connectionresetbypeer
Connectionto121.248.200.15closed.
如果sshclient窗口在几分钟内没有键盘操作的时候会话就会超时断线,通过修改sshd的配置文件能够让sshserver发送“心跳”信号来维持持续链接,
打开服务器/etc/ssh/sshd_config文件最后添加一行
ClientAliveInterval60指定了服务器端向客户端请求消息的时间间隔,默认是0,不发送.而ClientAliveInterval60表示每分钟发送一次,然后客户端响应,这样就保持长连接了
ClientAliveCountMax1表示服务器发送请求后,客户端没有响应的次数达到了一定的值,就会自动断开。
PS
[oracle@hadoop~]$mansshd_config
ClientAliveCountMax
Setsthenumberofclientalivemessages(seebelow)whichmaybesentwith-outsshdreceivinganymessagesbackfromtheclient.Ifthisthresholdisreachedwhileclientalivemessagesarebeingsent,sshdwilldisconnecttheclient,terminatingthesession.ItisimportanttonotethattheuseofclientalivemessagesisverydifferentfromTCPKeepAlive(below).Theclientalivemessagesaresentthroughtheencryptedchannelandthereforewillnotbespoofable.TheTCPkeepaliveoptionenabledbyTCPKeepAliveisspoofable.Theclientalivemechanismisvaluablewhentheclientorserverdependonknowingwhenaconnectionhasbecomeinactive.Thedefaultvalueis3.IfClientAliveInterval(seebelow)issetto15,andClientAliveCountMaxisleftatthedefault,unresponsivesshclientswillbedisconnectedafterapproximately45seconds.
ClientAliveInterval
Setsatimeoutintervalinsecondsafterwhichifnodatahasbeenreceivedfromtheclient,sshdwillsendamessagethroughtheencryptedchanneltorequestaresponsefromtheclient.Thedefaultis0,indicatingthatthesemessageswillnotbesenttotheclient.Thisoptionappliestoprotocolversion2only.