I'm not sure this is possible. What I want to do is make the sort of
assignment we see in /etc/hosts but have it work only within a script.
Here's the problem. machineA is behind a firewall, but it is accessible
via ssh from machineB, so I've written a script that lets me to ssh to
machineA via ssh through machineB using port forwarding:
ssh -f -L 25922:machineA:22 ${USERB}@machineB sleep 1 ; ssh -X -p 25922 ${USERA}@localhost
It would be nice if I could use scp in a fairly straightforward way while
connected that way. (Ignore usernames for the rest of this to keep it
simple.) For example, I wish this would just work:
scp machineA:file .
That can't work, but can I write a script that would make it work? That
script would read that command and execute this one:
scp -P 25922 localhost:file .
So it would be neat if I could write the script so that it could
automatically convert "machineA" to localhost or 127.0.0.1. I have this
line in /etc/hosts:
127.0.0.1 localhost
Is there any way to basically make this assignment inside of the script
(so that it doesn't change anything except within the script)?:
127.0.0.1 localhost machineA
Then something like this might work in a script:
scp -P 25922 $*
The user could then just do something like this:
scpA.bash machineA:file .
Is there any hope of making that work? If not, maybe I can search for
"machineA" and replace with localhost.
Mike