Reputation: 3059
I need to make a service that can copy a file from one remote server to another remote server. I could just run this in a subshell:
scp user@host1:/path/to/file/video.mp4 user@host2:/path/to/file
But that doesn't seem nearly as good as using something like fabric's put command, which only copies a local file to a remote machine. I also need this to run entirely with ssh keys, no password prompting.
Upvotes: 3
Views: 6622
Reputation: 1795
You can use get
to get the file from host1 and then put
to push it to host2.
For keys, if the private key isn't in the default location, you can specify it with the -i
flag, e.g.:
fab -i /path/to/priv/key
or put it in the fabfile:
from fabric import env
env.key_filename = '/path/to/priv/key'
Upvotes: 4
Reputation: 921
Also there is a possibility where agent forwarding can be used(as of fabric 1.10, with option -A). In which case you can just run the following command from host1
scp /path/to/file/video.mp4 user@host2:/path/to/file
or from host2:
scp user@host1:/path/to/file/video.mp4 /path/to/file
Upvotes: 4