title: scp execution fails when when executed from a script after udev rule trigger - Script works if executed manually or through cron
body: <p>Good evening
  I have set proxmox server on an old laptop , where I run a couple of VM's. I created an udev rule to copy a file (uevent) from host (Proxmox) to one of the VM's (home assistant) when  the power is disconnected
  The problem I'm running into is that when udev executes the script the scp line times out.</p>
  <p>ssh from host to vm works fine and I can even run the scp command manually:</p>
  <pre><code>/usr/bin/scp -v /root/uevent1.json root@192.168.7.48:/root/config/BAT1
  </code></pre>
  <p>I also can run the script that udev is supposed to execute and works fine (batupdate1.sh):</p>
  <pre><code>#!/usr/bin/bash
  FILE=/sys/class/power_supply/BAT1/uevent
  awk -F'=' 'BEGIN {printf &quot;{&quot;} /POWER_SUPPLY/  {printf &quot;\&quot;&quot; $1 &quot;\&quot;:\&quot;&quot; $2 &quot;\&quot;,&quot;} END {print &quot;}&quot;}'  $FILE | sed 's/,}/}/' &gt;/root/uevent1.json
  /usr/bin/scp -v /root/uevent1.json root@192.168.7.48:/root/config/BAT1
  </code></pre>
  <p>udev rule:</p>
  <pre><code>SUBSYSTEM==&quot;power_supply&quot;, ACTION==&quot;change&quot;, RUN+=&quot;/usr/local/bin/batupdate1.sh&quot;
  </code></pre>
  <p>This is how the syslog looks like for this particular script:</p>
  <pre><code>: ADP1: RUN '/usr/local/bin/batupdate1.sh' /etc/udev/rules.d/80-local.rules:2
  : Starting '/usr/local/bin/batupdate1.sh'
  : '/usr/local/bin/batupdate1.sh'(err) 'Executing: program /usr/bin/ssh host 192.168.7.48, user root, command scp -v -t /root/config/BAT1'
  : '/usr/local/bin/batupdate1.sh'(err) 'OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d  10 Sep 2019'
  : '/usr/local/bin/batupdate1.sh'(err) 'debug1: Reading configuration data /root/.ssh/config'
  : '/usr/local/bin/batupdate1.sh'(err) 'debug1: Reading configuration data /etc/ssh/ssh_config'
  : '/usr/local/bin/batupdate1.sh'(err) 'debug1: /etc/ssh/ssh_config line 19: Applying options for *'
  : '/usr/local/bin/batupdate1.sh'(err) 'debug1: Connecting to 192.168.7.48 [192.168.7.48] port 22.'
  : Spawned process '/usr/local/bin/batupdate1.sh' [30840] is taking longer than 59s to complete
  : '/usr/local/bin/batupdate1.sh'(err) 'debug1: connect to address 192.168.7.48 port 22: Connection timed out'
  : '/usr/local/bin/batupdate1.sh'(err) 'ssh: connect to host 192.168.7.48 port 22: Connection timed out'
  : '/usr/local/bin/batupdate1.sh'(err) 'lost connection'
  : Process '/usr/local/bin/batupdate1.sh' failed with exit code 1.
  </code></pre>
  <p>I have tried everything, started and restarted udev service , the whole server and nothing seems to make scp work from a script when called from a udev trigger</p>
  <p>Any help will be enormously appreciated
  Thanks!</p>