Skip to content

Add support for configuring a dedicated SSH key file per author #548

@hnrobert

Description

@hnrobert

Summary

Add support for configuring a dedicated SSH key file per author, so that when switching authors via git-mob, the corresponding SSH identity can also be switched automatically for Git operations (e.g., push).


Motivation

Currently, git-mob focuses on managing co-author metadata (name/email), but in multi-account environments (e.g., personal + work GitHub accounts on GitHub), author identity is often tightly coupled with SSH credentials.

A common workflow issue:

  • Different authors correspond to different GitHub accounts
  • Each account requires a distinct SSH key
  • Git itself selects SSH keys independently of git config user identity
  • As a result, switching author via git-mob does not ensure the correct authentication identity is used during git push

This leads to frequent errors such as:

  • Write access to repository not granted
  • Authentication as the wrong user

Desired behavior

When switching author via git-mob:

  • The corresponding SSH key should also be selected automatically
  • Git operations (especially push) should use the correct identity without manual overrides

Example use case

  • Selecting alice as the main author -> automatically uses ~/.ssh/id_ed25519_alice
  • Selecting bob as the main author -> automatically uses ~/.ssh/id_ed25519_bob

This would align author identity (commit metadata) with authentication identity (SSH key), reducing friction in multi-account workflows.


Describe alternatives you've considered

1. Manual SSH command override

GIT_SSH_COMMAND="ssh -i ~/.ssh/key" git push
  • Works, but not scalable
  • Requires manual intervention every push

2. Git config per-repo

git config core.sshCommand "ssh -i ~/.ssh/key"
  • Static, not compatible with dynamic author switching

3. SSH config with multiple hosts

Host github-work
  IdentityFile ~/.ssh/work_key

Host github-personal
  IdentityFile ~/.ssh/personal_key
  • Requires changing remote URLs
  • Breaks abstraction git-mob provides
  • Not author-driven

4. Wrapper scripts / aliases

  • Adds complexity outside the extension
  • Hard to maintain and onboard for teams

Proposed approach

Extend git-mob configuration to support SSH key mapping, similar to (not necessarily the final version, just for ref)

{
  "gitMob.authorSSHKeys": {
    "alice": "~/.ssh/id_ed25519_alice",
    "bob": "~/.ssh/id_ed25519_bob"
  }
}

When switching author, we can do things similar to:

  • Update core.sshCommand dynamically, or
  • Inject GIT_SSH_COMMAND for Git operations triggered via the extension

Additional context

This would be a relatively large change, as it crosses from identity management into Git transport configuration.

If this is considered out of scope for the project, I am happy to explore this as a separate fork or extension.

However, given how common multi-account setups are, this feature could significantly improve usability for teams working across multiple Git identities.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions