I think you cannot use
~/.ssh/config to solve your problem because this file is for
ssh, not for
scp. It's true
ssh under the hood, but
-O you want to force is an option strictly for
scp, not for
You may be able to achieve an acceptable result with a wrapper script. This is the script:
exec /usual/path/to/scp -O "$@"
You need to use the full path to the real
scp. Save the script as
scp in a directory that is earlier in your
$PATH than all other directories in
$PATH that hold other (in practice: the real)
scp executable(s). Create a new directory and adjust your
$PATH if needed. Make the script executable (
chmod +x scp).
From now on any process that inherits your modified
$PATH and tries to run
scp will run the wrapper instead of the real
scp. The wrapper will replace itself with the real
scp that will get
-O along with all arguments passed to the wrapper. This way
-O will be injected automatically.
There are cases when the method cannot work:
If a process calling
$PATH which is not your modified
$PATH then it won't find the wrapper and it will run the real
scp directly; so
-O won't be injected. For this reason you may want to modify
$PATH as "globally" as possible.
If a process calls
/usual/path/to/scp explicitly then it will obviously call the real
scp directly regardless of
-O won't be injected.
A way to overcome these is:
- Do not modify
- Move the original
scp to a different pathname.
- Use this pathname in the wrapper, so the wrapper execs to the real
scp as it always should.
- Save the wrapper as
The downside is your OS, when being upgraded, may replace the wrapper with a new version of the real
scp. This mishap cannot happen in the method with modified
$PATH and unaltered