Avoid ssh session time out

2019-05-26 11:21发布

问题:

I am remotely working on a server that automatically logs me out after 5 minutes of inactivity. Here's the message that it usually provides when it does so:

Read from remote host XXXXXXX: Operation timed out

I typically have several sessions open, which I use at roughly 30-minute intervals, so I wonder what I could do to avoid getting disconnected. I've already tried:

  • [a] hiring a monkey to hit some keys before the session logs me out
  • [b] running the top command
  • [c] threatening the server administrator :)

Any other suggestions? Thanks.

回答1:

This has been answered on StackOverFlow - I add the link here for people that don't want to go to a third party forum when they search for this answer (as I did):

https://stackoverflow.com/questions/13390710/mac-terminals-how-to-keep-alive

Add to ~/.ssh/config

ServerAliveInterval 30

or start your ssh session using:

ssh -o ServerAliveInterval 30 username@hostname

And BTW: the answer is not specific to Mac.



回答2:

You might consider using vi or more to edit a file.



标签: session ssh exit