PROBLEM: Dialing into my dedicated Ubuntu server the connection drops if I am not active for a relatively short time of about 2 minutes.
SOLUTION: IMPLEMENTED: Added the ServerAliveCountMax ServerAliveInterval entries to the client side ssh config file.
Solution
- Client_loop: send disconnect: Broken pipe – Critical find
- ssh -o TCPKeepAlive=yes -o ServerAliveCountMax=20 -o ServerAliveInterval=15 root@IP_address
- This appears to imply the server has not been restarted when the restart and / or reload commands were issued.
- Restart server and see if these statments are still required. > Updated and rebooted. Still did not hold the connection longer than ~2 minutes.
- Checked server and client side config file and I do not see ServerAliveCountMax ServerAliveInterval in either file
- Which side do the settings: ServerAliveCountMax ServerAliveInterval entries belong in? Is it safe to assume in the SSH_Config files?
- Linux and VMWare: SSH avoid disconnection inactivity ( original in Spanish – link includes translation ) – see snippet below: my guess appears to have been correct – add the entries to client side says this reference
From the SSH client side:
If the client is Linux: Edit the configuration file: ssh_config
- At user level: ~/.ssh/config
- or for all users: /etc/ssh/ssh_config
Add:
Host *
ServerAliveInterval XX
ServerAliveCountMax YY
Differences in names between server and client SSH configuration file names
- etc/ssh/sshd_config is folder name on server
- etc/ssh/ssh_config on client
Research Links
- Goo: ubuntu ssh session times out
- How to Increase SSH Connection Timeout in Linux – this looked like it should do it but appears to have an error and or omission? sshd.service not found
- Goo: ubuntu sshd service not found
- Unit sshd.service not found – suggests using: systemctl restart ssh – still timed out
- Goo: ubuntu ssh time out too short
- Ubuntu: ssh terminal always freezes after ~ 2minutes of inactivity – says to modify same above values and also set TCPKeepAlive yes
- tried systemctl restart ssh – again timed out
- How To Use SSH to Connect to a Remote Server -good overview. Includes keys / ports. It uses: sudo systemctl reload ssh for the reload but as noted that has not worked to date. Covers all the features – using keys.
- How to Fix “Connection Timed Out” in SSH – shows how to access the logs
- Ubuntu: OpenSSH server
- Ubuntu: Installed SSH but no SSHD found – talks server and client version of OpenSSH
Steps
- Using vi > Set the values to: ClientAliveInterval 1200 ClientAliveCountMax 3
- Saved using :wq
- Attempted to restart SSH using specified command: systemctl reload sshd
- comes back with sshd.service not found
- tried to restart using systemctl reload ssh – appeared to execute. Still timed out after this.
SSH Notes:
- What is sshd in Ubuntu? sshd (OpenSSH Daemon) is the daemon program for ssh.
vi editor notes
- Hit insert key to start writing over text
- type :wq to write and quit.
:wq
To save a file, you must first be in Command mode. Press Esc to enter Command mode, and then type :wq to write and quit the file. The other, quicker option is to use the keyboard shortcut ZZ to write and quit.
0 Comments