0

I have a script that goes out to 5 other Rpi3 computers and collects data from them using scp and puts it all out on a flash drive. (Then later it gets picked up from the master Pi by a Windows Task for backup to a hard drive.)

It needs to be put into cron so I don't need to initiate it manually. But it prompts for the password of each remote Pi as it runs.

How do I solve this?

For reference, you can see a description of my entire Rpi3 network in my answer to this question:

How can I connect 5 Raspberry Ppi's?

SDsolar
  • 2,378
  • 8
  • 26
  • 43

1 Answers1

0

I found that this is really easy.

First, I generated a public key on my master unit that can be shared with the other computers.

ssh-keygen

Just press enter to the three questions.

Then, I appended my public key to the other servers like so:

ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host

where remote-host is a name of the other server from my /etc/hosts file

It will prompt you to accept the other host's key - you answer yes (not just y) Then it will prompt you for the other server's password.

I ran that the ssh-copy-id -i command for each of the 5 remote Pi3s, using their name from MASTER's /etc/hosts file. It works with plain IP addresses also.

That's it. Now my script runs with no prompting.

Best of all, it works in cron so I don't even need to be here when it runs.

SDsolar
  • 2,378
  • 8
  • 26
  • 43