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?
custom-scriptto do differently for scp connections. – Kenster May 11 '22 at 15:49scpsimply runssshwith arguments (see "what happens under the hood" here). There is no token because from the point of view ofsshthe situation is no different from a shell (or whatever) runningsshwith arguments. Unless yourscpuses SFTP (see OpenSSH SCP deprecation in RHEL 9: What you need to know). – Kamil Maciorowski May 11 '22 at 16:00