I have a task requiring that USER_A run a script, which connects to HOST_B as USER_B and does not ask for a password.
If I am logged in on HOST_A as USER_B, I can connect to HOST_B without a password, no problem. However, if I try running ssh with the command line "ssh USER_B@HOST_B" while logged in as USER_A, it asks for USER_B's password on HOST_B.
What am I doing wrong? Is there a way around this?
Actually, it looks like I figured this out. It seems if I put the public key from USER_A into USER_B's authorized_hosts, it works. However, my real issue is I have users A-Z who all need to connect to HOST_B as USER_B. Would I just need to copy USER_A's public key to USER_B-USER_Z's .ssh directory for that to work?
If the first works, you can. Else you need to proceed to the key exchange as USER_B and then copy the key from USER_B to other users who will need to ssh USER_B@SERVER.