[SOLVED] how can i fix ssh timeout?

Issue

This Content is from Stack Overflow. Question asked by Leonard Sangoroh

I have created a droplet on Digital Ocean and installed CentOS as its OS. I would like to resolve the frequent timeout of the remote ssh connection. I found a guide on this link how can i fix ssh timeout? . I have successfully navigated to /etc/ssh/ directory. When I list available sub-directories in /etc/ssh/ directory, I am able to see sshd_config sub-directory. However, when I try moving into the sub-directory I get the error “bash: cd: /etc/ssh/sshd_config: Not a directory.”
What could I be doing wrong?

Below is what I’ve keyed in the terminal

[root@centosFirstServer134327 ssh]# pwd
/etc/ssh

[root@centosFirstServer134327 ssh]# ls
moduli        ssh_host_ecdsa_key      ssh_host_ed25519_key.pub  sshd_config
ssh_config    ssh_host_ecdsa_key.pub  ssh_host_rsa_key
ssh_config.d  ssh_host_ed25519_key    ssh_host_rsa_key.pub

[root@centosFirstServer134327 ssh]# cd /etc/ssh

[root@centosFirstServer134327 ssh]# cd /etc/ssh/sshd_config
bash: cd: /etc/ssh/sshd_config: Not a directory



Solution

Can you go to this directory to edit ssh file

cd /etc/ssh/sshd_config

change
ClientAliveInterval 120
ClientAliveCountMax 720

This will make the server send the clients a “null packet” every 120 seconds and not disconnect them until the client have been inactive for 720 intervals (120 seconds * 720 = 86400 seconds = 24 hours).


This Question was asked in StackOverflow by 김연경 and Answered by MKirat It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?