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?

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.

  • It works! I use it every day now. This same method works on Ubuntu 14.04 LTS also, after openssh-server is installed. – SDsolar Jul 6 '17 at 7:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.