how to set ssh ControlMaster=no when using sftp or scp

de flag

I want to use SSH multiplexed connections and also forward my SSH agent.

When the SSH persistent socket is created by scp or sftp, the agent is not forwarded (see If I then use ssh over the same socket then the agent is not available.

If ssh creates the persistent socket then the agent IS available.

Is there a way to have "ControlMaster no" for sftp/scp but auto for ssh?

In my ~/.ssh/config I have

Host *
    ControlMaster auto
    ControlPath ~/.ssh/master_%r@%h:%p
    ControlPersist 180
    ForwardAgent yes
de flag

This seems to be a known issue since 2016 with no official solution:


Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.