How to do SCP between non login shell users?
I have looked previously asked question on this topic but found no matches what I am looking for.
Scenario:
There are two centos systems, let's say, System1 and System2.
A script in System1 uses a non-login shell user(user1) to download file from web and places it at the user's home directory(/home/user1).
Another script in System2 uses a non-login shell user(user2) to scp file from system1 and do some operation.
These users are created while installing the script in both systems using root user.
below is the snippet of the spec file which is creating user1 and user2.
challenge: the conventional way to do passwordless scp is to create a pair of keys and copy public keys in the remote systems. But how can i generate the user-specific key and copy to it the remote server if I cannot login?
please advise me a good approach to handle this requirement.