UDR fan controlled by ssh - how to automate it?

Hello guys,
Recently I got Unifi Dream Router and I’ve a little problem. Fan in this device is quite too loud. Its a way to make him more quiet by execute ssh command. And my question is:

  1. How can I make in Home Assistant passwordless ssh access to my router to control that? Currently I can change it by typing 3 commands in ssh after connect via HA Terminal.

  2. It is possible to automate it? In example, when I am not in home, it execute command “echo 70 > pwm1” and if I am at home “echo 50 > pwm1” but every 5 minutes? (cause after change it restore previous “loud” state)