I'm currently working on a project I inherited that requires me to document the process for setting up a device we use to reimage our machines and install software on them.
I'm using a Raspberry Pi as the host to install the OS and software and have run into issues with one last part of the installation script which requires me to be able to execute a command via SSH and get the return value. The command I'm trying to execute is as follows:
ssh -o StrictHostKeyChecking=no host uname -a &>/dev/null
rc=$?
That is the command verbatim. No user is specified for the host and no password is passed in, so it is authenticated via keys, I assume. I don't know much about SSH, but since each Pi is supposed to have an identical image on it, I would assume the SSH keys would be the same, so I copied the contents of /etc/ssh from the old one to the new one. I didn't bother to copy the contents of ~/.ssh because the only file in that directory on BOTH devices is known_hosts.
However, despite having the same setup and same SSH keys, the old one is able to execute this command with no fuss, while the new one prompts for the root@host password.
What else could be affecting my ability to execute this command? Am I missing some obscure SSH configuration? I have looked at just about everything I could find on Google and the only answer I could find was to generate a key on the machine that needs to execute the command and install it on the host's authorized_keys file -- but since the Pi does not even have this file, and the old Pi already has keys in /etc/ssh which I assume are used for this purpose, I don't understand why a new Pi with the same setup and same keys should fail to authenticate.