I use ssh -p8520 username@remote_host
to login remote server.
Issue:
It is always connected and works properly when I am in the work place. Unfortunately, terminal freezes in 10 - 15 minutes after I connected with the remote server from home.
There's no error/timeout report on the console but the cursor cannot move any more.
When enter w to check the login users, some zombies login users are there, and I have to kill them manually.
This is quite annoying. Can anyone help me?
sshd (the server) closes the connection if it doesn't hear anything from the client for a while. You can tell your client to send a sign-of-life signal to the server once in a while.
The configuration for this is in the file "~/.ssh/config", create it if the configuration file does not exist. To send the signal every four minutes (240 seconds) to the remote host, put the following in your "~/.ssh/config" file.
This is what I have in my "~/.ssh/config":
To enable it for all hosts use:
Also make sure to run:
because the config file must not be world-readable.
For those wondering, @edward-coast
If you want to set the keep alive for the server, add this to
/etc/ssh/sshd_config
:I wanted a one-time solution:
Stored it in an alias:
Now can connect like this:
FYI Putty Users can set the options here
We can keep our ssh connection alive by having following Global configurations
Add the following line to the
/etc/ssh/ssh_config
file: