I wrote a script which downloads via scp
and installs some packages. SSH keys are added to host and when I run
[root@HostB ~]# ./myscript
everything is ok and packages are downloaded via scp without asking for password.
I need to run this script via ssh
but when I try
[root@HostA ~]# ssh root@HostB "./myscript"
I get Permission denied (publickey,password) error.
When I'm trying to use ssh -t
I get a password enquiry in place when scp
command in myscript is executing.
ssh root@HostB
?myscript
. What you actually need to figure out is why yourscp
commands complete without a password prompt when you run them locally, but ask for a password when you're running remotely. My guess is you're relying on an SSH agent for keys that is not being forwarded in the remote script execution case.