public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Add support for per-remote and per-namespace SSH options
@ 2026-03-26 23:37 Wesley Schwengle
  2026-03-26 23:37 ` [PATCH 1/3] connect: Rename name to command in connect_git() Wesley Schwengle
                   ` (3 more replies)
  0 siblings, 4 replies; 22+ messages in thread
From: Wesley Schwengle @ 2026-03-26 23:37 UTC (permalink / raw)
  To: git

With this changeset applied git is now aware of `sshIdentityFiles' and
`sshOpts'. This allows users to have multiple accounts on the same forges.
A common problem within the developer community. This problem is often
solved by hacking in one's `.ssh/config' and changing hostname URIs to
ensure the correct key is being used.

For years I had zsh wrapper script that was used as the `core.sshCommand' and
is a reference implementation of this change.

In order of importance:

Configuration on the remotes itself. This is easy, straight forward and
should allow people to get it to work quickly:

* `remote.*.sshIdentityFile' and `remote.*.sshOpts'

Configuration set on owner/path style. This is to support `includeIf`
configuration management. For example, a git-forge that host both
employer/client repo's. Eg, `git@gitlab.com/waterkip/git.git' and
`git@gitlab.com/corp/git.git' would have something configured as:

* `core.sshIdentityFile.*', eg

    [core "sshIdentityFile"]
      waterkip = ~/.ssh/id_ed25519_me
      corp     = ~/.ssh/id_ed25519_corporate

And finally, a global override for everything:

* `core.sshIdentityFile' and `core.sshOpts'

I stayed within the `core' namespace, mainly because `core.sshCommand'. I'm
happy to move it to `ssh' or something similar. It would perhaps make
`ssh.*.sshIdentifyFile' more structured, because now that's split between two
core subsections.

The following assumptions have been made to make it safe and sound for
users. When an `sshIdentityFile' is used and no `sshOpts' are configured git
will inject `-F /dev/null' to prevent cycling over all sshIdentityFiles
a user has in their `.ssh/config'. When a user configures `sshOpts', these
take precedence and a user itself is responsible for setting
`-F /dev/null'.

Separate push/pull URIs are not supported by the feature. The biggest problem
with this is that I don't know how to properly configure them with the
namespace constraints. `remote.*.xyz' is as deep as git can go and a push/pull
would require additional configuration. I filed it under edge-case.

There are two new structs introduced: `ssh_options' and `cnx_context'.
They are there to limit the amount of argument passing down the wire. And this
is especially true for `ssh_options' because it keeps `push_ssh_options' dumb.

Wesley Schwengle (3):
  connect: Rename name to command in connect_git()
  connect: Add transport->remote->name to git_connect()
  connect: Add support for per-remote and per-namespace SSH options

 Documentation/config/core.adoc   |  22 ++++
 Documentation/config/remote.adoc |   9 ++
 builtin/fetch-pack.c             |   2 +-
 builtin/send-pack.c              |   2 +-
 connect.c                        | 144 ++++++++++++++++++++--
 connect.h                        |   2 +-
 t/t57xx-ssh-options-config.sh    | 198 +++++++++++++++++++++++++++++++
 transport.c                      |   9 +-
 8 files changed, 375 insertions(+), 13 deletions(-)
 create mode 100755 t/t57xx-ssh-options-config.sh

-- 
2.53.0.722.g8e572876c5


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2026-03-28  7:47 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-26 23:37 [PATCH 0/3] Add support for per-remote and per-namespace SSH options Wesley Schwengle
2026-03-26 23:37 ` [PATCH 1/3] connect: Rename name to command in connect_git() Wesley Schwengle
2026-03-27 21:33   ` Jeff King
2026-03-28  0:58     ` Wesley
2026-03-28  1:44       ` Jeff King
2026-03-28  2:01         ` Wesley
2026-03-26 23:37 ` [PATCH 2/3] connect: Add transport->remote->name to git_connect() Wesley Schwengle
2026-03-27 21:39   ` Jeff King
2026-03-26 23:37 ` [PATCH 3/3] connect: Add support for per-remote and per-namespace SSH options Wesley Schwengle
2026-03-27 21:45   ` Jeff King
2026-03-28  0:43     ` Wesley
2026-03-28  2:03       ` Jeff King
2026-03-28  2:25         ` Wesley
2026-03-27  7:51 ` [PATCH 0/3] " Johannes Sixt
2026-03-27 15:04   ` Wesley
2026-03-27 16:10   ` Junio C Hamano
2026-03-27 16:49     ` Wesley
2026-03-27 22:06       ` brian m. carlson
2026-03-28  1:02         ` Wesley
2026-03-28  7:46       ` Johannes Sixt
2026-03-27 21:51     ` brian m. carlson
2026-03-27 22:25       ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox