I'm wondering how to copy a file with scp (or a better way if possible) and allow ssh key forwarding. I've read a lot of posts on how to do this closely, but not with ssh forwarding, or the -A equivalent we get with ssh.
Backstory - I have keys added with the method-
ssh-add mkey.pem so that I can ssh into a bastion host with those stored keys like so... [localhost]$ ssh -A user@bastion
...and then ssh into the server from the bastion, which will automatically use the ssh keys added from the localhost. [bastion]$ ssh -A user@server
However, scp doesn't have an equivalent -A function to use a stored key from the localhost, which prevents you from having to store the key on the bastion.
What is the ideal approach to copying a file from a server via a bastion host that requires ssh keys for access?
scp
supports passing options to ssh
via the -o
argument.
In this case, I think the best way to address this is to use scp -o "ForwardAgent yes"