I need to do a rsync from a target server with a server in the middle and I have the same public key on both the target and middle server. I want to use that key so I don't have to do password authentication.
local --ssh--> middle --ssh--> target
Reading Method 1 of Using rsync through a firewall makes it seems like this is doable but I have been able to figure out the ssh part of the syntax of the command yet.
When I try
ssh -i $KEY -A user@middle ssh user@target
I get
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
Clearly the agent forwarding isn't happening as I was expecting it to.
Ideally I'd like to fit it all in one command without have to put anything in ~/.ssh/config files. What are all of the steps to do an rsync in this situation?
Thanks, Everett
The '-A' will only "carry" identities loaded into ssh-agent. ('-i' on the command won't be enough.)
How about this something like this;
Personally I do this in two hops with the following script:
mod as required.
It seemed easier than playing with the rsync options and if your target and middle have your key you shouldn't be prompted.