0

I am trying to create a new ssh key, and copy it to a server, using a previously generated ssh key.

/usr/bin/ssh-copy-id  -f -i /home/pi/.ssh/newKey -o "IdentityFile=/home/pi/bob" user@host.edu

The following command is run using the rc.local (I also tried cron) and it will fail to copy the key to host.edu. But if I run the same command after I login locally to the pi, then it runs fine. How can I get this to run without logging onto the pi?

EDIT:

The rc.local runs the command is the pi user.

su pi -c '/home/pi/setup.sh'
Milhous
  • 133
  • 2
  • 9
  • did you schedule this command to run in the "user" of "pi" ? or in another user ? (e.g. root) you need to ensure that the user you schedule this command has the ability to read the key etc. – olivierg Apr 24 '18 at 20:35
  • Yes, I run it as the pi user. – Milhous Apr 24 '18 at 20:39
  • ok, and it might be a stupid question, but are you sure your shell script is executable ? also, can't you just deploy the key manually to the remote system ? (without using ssh-copy-id, but copying and pasting the public key manually) – olivierg Apr 24 '18 at 20:40
  • I dont want to do this manually for 100-1000 unique raspberry pi's. THere are multiple items that happen in the setup, and they all run, like the generation of a new ssh key. – Milhous Apr 24 '18 at 20:41
  • add one more line, to login to int, and then copy-id :) ssh -l user host.edu exit – BiG_NoBoDy Apr 24 '18 at 21:08

0 Answers0