Skip to main content
1 of 2
Torxed
  • 3.7k
  • 7
  • 33
  • 49

Most likely this is because your startup script will run in a root environment by default. Assuming that you're using ~/.ssh/id_rsa.pub as your mode of authentication (You never mentioned that you're using a password and using such a thing while automate is often a bad idea anyway, so i'll assume key authentication).

Then I'll go ahead and assume even further that you haven't allowed the (or even have a) root key generated that is trusted on your laptop?

You have two options in this case.

  1. run ssh-keygen as root, and copy the content of /root/.ssh/id_rsa.pub to your /home/<user>/.ssh/authorized_keys file.

or

  1. change your command to /usr/bin/ssh -i /home/<user>/.ssh/id_rsa.pub 'laptop_user'@'laptop_ip' "echo '### RaspberryPi 2 online ###' | /usr/bin/write 'laptop_user' pts/0"

The second is neater since it uses your users certificate that you already know works.

Torxed
  • 3.7k
  • 7
  • 33
  • 49