0

I manage SSH connections to remote machines using a special ProxyCommand in my ssh_config file. Suffice to say it's structured like this:

Host my-target
    IdentityFile /path/to/temporary-key
    ProxyCommand /path/to/custom-script %n %r %p /path/to/temporary-key

As you can see, when I enter ssh me@my-target, SSH will read this file and execute the custom-script, passing it the hostname, user, (default) port, and a path to the private key it will attempt to use to authenticate to the server (which the custom script will generate in real time). This works just fine.

However, I would like for the custom-script to behave differently depending on whether it was invoked via ssh vs. scp. As far as I'm aware, there is no ssh_config token that stores this, but it seems like it should be possible in theory.

Is there a way to pass this information to my ProxyCommand?

  • [The XY problem](https://xyproblem.info/) You might get better advice if you [edit] your question to describe what you'd like `custom-script` to do differently for scp connections. – Kenster May 11 '22 at 15:49
  • 1
    `scp` simply runs `ssh` with arguments (see "what happens under the hood" [here](https://superuser.com/a/1634882/432690)). There is no token because from the point of view of `ssh` the situation is no different from a shell (or whatever) running `ssh` with arguments. Unless your `scp` uses SFTP (see [*OpenSSH SCP deprecation in RHEL 9: What you need to know*](https://www.redhat.com/en/blog/openssh-scp-deprecation-rhel-9-what-you-need-know)). – Kamil Maciorowski May 11 '22 at 16:00

0 Answers0