-1

I have a remote tunnel set up using this:

ssh -R 2022:127.0.0.1:2222 -N -f [email protected] -i .ssh/djangoserver

The remote machine can SSH successfully but the connection only lasts about 10 minutes before it either times out or locks up.

The keyboard does not respond and I have to kill the session on the remote machine then login again after that I cannot connect to the local machine

1
  • Your last comment suggested the answer didn’t resolve your issue
    – Ramhound
    Jan 11, 2022 at 12:18

1 Answer 1

2

Your post does not contain information why the connection timeout happens. If the server terminates the connection because the client was silent for too long, you can set the ServerAliveInterval (assuming you are using OpenSSH).

From the man page

Sets a timeout interval in seconds after which if no data has been received from the server, ssh(1) will send a message through the encrypted channel to request a response from the server. The default is 0, indicating that these messages will not be sent to the server.

The configuration for this goes into $HOME/.ssh/config on the client. If you want to send the signal every minute to the remote host example.net, put the following in the configuration file:

Host example.net
    HostName example.net
    ServerAliveInterval 60

You can enable it for all host if you use a wildcard

Host *
    ServerAliveInterval 60

You can set a similar option on the server side in /etc/ssh/sshd_config. It is called ClientAliveInterval. This could be helpful if you run the server yourself and don't want to customize all your clients.

From the man page

Sets a timeout interval in seconds after which if no data has been received from the client, sshd(8) will send a message through the encrypted channel to request a response from the client. The default is 0, indicating that these messages will not be sent to the client. This option applies to protocol version 2 only.

6
  • Should this directive be in .ssh/config on both the remote and local machines? Jan 10, 2022 at 21:45
  • @DennisGray - Only on the server. Configuration of the server on the client would only effect the server configuration on the client not the server
    – Ramhound
    Jan 11, 2022 at 1:52
  • I set the directive on the client and it is not timing out but I'll put it on the server only later Jan 11, 2022 at 6:59
  • @DennisGray ServerAliveInterval is a client-side configuration option, it belongs to ssh_config, not sshd_config. The server-side counterpart is ClientAliveInterval. See this answer. Jan 12, 2022 at 12:16
  • I'll give those a try. Jan 14, 2022 at 11:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .