Command Line sensor to remote host stops working suddenly

Hi!
I was using HA on docker but got a new pi then setup a new HA to pi with the official 64 bit image.
I have one old NAS device and I am using command line sensor to get some data from it.
commands are like this:

  #CPU TEMP
- platform: command_line
  name: "LCM CPU TEMP"
  command: ssh -T -o StrictHostKeyChecking=no -i /config/ssh/id_rsa [email protected] "cat /sys/class/thermal/thermal_zone0/temp"
  value_template: '{{ ((value | float) / 1000) | round(1) }}'
  unit_of_measurement: '°C'
  scan_interval: 10
  command_timeout: 5

#MEMORY USED
- platform: command_line
  name: "LCM RAM"
  command: ssh -T -o StrictHostKeyChecking=no -i /config/ssh/id_rsa [email protected] "top -bn1 | head -3 | awk '/Mem/ {print \$2}'"
  value_template: '{{( (value | replace("K","") | float / 1024) | round(0) | int )}}'
  unit_of_measurement: 'MB'
  scan_interval: 10
  command_timeout: 5

  #MEMORY FREE
- platform: command_line
  name: "LCM Free RAM"
  command: ssh -T -o StrictHostKeyChecking=no -i /config/ssh/id_rsa [email protected] "top -bn1 | head -3 | awk '/Mem/ {print \$4}'"
  value_template: '{{( (value | replace("K","") | float / 1024) | round(0) | int )}}'
  unit_of_measurement: 'MB'
  scan_interval: 10
  command_timeout: 5

  #MEMORY TOTAL
- platform: command_line
  name: "LCM Total RAM"
  command: ssh -T -o StrictHostKeyChecking=no -i /config/ssh/id_rsa [email protected] "cat /proc/meminfo | awk '/MemTotal/ {print \$2}'"
  value_template: '{{ ((value | int) / 1024) | int  }}'
  unit_of_measurement: 'MB'
  scan_interval: 3600
  command_timeout: 5

  #TOTAL SPACE
- platform: command_line
  name: "LCM Total Space"
  command: ssh -T -o StrictHostKeyChecking=no -i /config/ssh/id_rsa [email protected] "df | awk '/md1/ {print \$2}'"
  value_template: '{{((value | int) / 1024 / 1024 / 1024) | float | round(2)}}'
  unit_of_measurement: 'TB'
  scan_interval: 360
  command_timeout: 5

  #USED SPACE
- platform: command_line
  name: "LCM Used Space"
  command: ssh -T -o StrictHostKeyChecking=no -i /config/ssh/id_rsa [email protected] "df | awk '/md1/ {print \$3}'"
  value_template: '{{((value | int) / 1024 / 1024 / 1024) | float | round(2)}}'
  unit_of_measurement: 'TB'
  scan_interval: 360
  command_timeout: 5

Everything is working fine but after some time(10-30mins), these commands do not work. I tried to ssh into the “LCM” machine from home assistant console but it has timed out.
running in verbose gives this output which is not helpful:

config $ ssh -v [email protected]
OpenSSH_8.3p1, OpenSSL 1.1.1g  21 Apr 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to 192.168.1.42 port 22.
debug1: connect to address 192.168.1.42 port 22: Operation timed out
ssh: connect to host 192.168.1.42 port 22: Operation timed.

I can ssh into the “LCM” from other machines but not from the home assistant. Rebooting LCM fixes the issue temporarily but it comes back again after some time. I am suspecting that home assistant opens too many ssh connections without terminating them so the host machine refuses to establish more connections. Doesn’t -T command switch supposed to terminate the connection after the command though?
I am stuck. Any help?

sshd_config of the host machine:

Port 22
Protocol 2
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_rsa_key
SyslogFacility AUTHPRIV
AllowUsers sshd
PermitRootLogin yes
PubkeyAuthentication yes
PermitEmptyPasswords yes
PasswordAuthentication yes
ChallengeResponseAuthentication no
TCPKeepAlive yes
PubkeyAcceptedKeyTypes +ssh-dss
HostKeyAlgorithms +ssh-dss
Ciphers +blowfish-cbc
MaxAuthTries 5
Subsystem sftp /usr/bin/sftp-server