I want to copy a file from server-a to server-d but I can access server-d only from server-b and then to server-c. server-a can only access server-b, server-b can only access server-c, server-c can only access server-d..
Currently I do it like this:
server-a> scp /tmp/file.txt user@server-b
server-a> ssh user@server-b
server-b> scp /tmp/file.txt user@server-c
server-b> ssh user@server-c
server-c> scp /tmp/file.txt user@server-d
This could be through 5,6,7,.. servers
Can I do this is one command?
Best Answer
You need the
ProxyCommand
, see the man page. Here's an example:This allows you to type
ssh serverB
and you connect to serverA which then connects to serverB. This can easily be extended to work with ? host. It will work withscp
the same way it does forssh
.