Page:
Git Multi SSH
Pages
APT WhatProvides
Apache wpadmin
Arch Default Kernel
Arch Kernel Order
Bash Add fd
Bash Dump History
Bash Trim Whitespace
CPU Stats
CSS Reset
DB2 Info
Debian Upgrade
Dell OpenManage
Diff Lines
Favicon Things
Find Examples
Forgejo Syntax Highlight
Git Combine Repos
Git Multi SSH
Git Quickstart
Git Rewrite User
GitLab Anchors
Gitea Mirror
Glibc IPv4
GnuPG Things
Home
IMAP Sync
IPv4 Default Gateway
IPv4 Default IP
KRB5 Empty Keytab
Kernel Boot Debug
Kernel Decompress
LICENSE
LUKS Encrypted Partitions
Linux Valid Usernames
Loopback FS
MP3 Get Tags
MX Tarpit
Makefile Template
Markdown Samples
Mount OVA
Mount qcow2
MySQL Connections
NFS 10G Tuning
Netcat Replacements
PAM Namespace
Postfix Headers
Proxmox Doodads
RPM Info
Radeon Temperature
Recover Deleted ext3
Recursive Unzip
Roku Info
SSH RSA Support
SSL Certgen
Samba OSX
Server Notes
Smem Datamash
Split Disk
TCP Kill
Thunderbird LDAP AD
Weechat Quickstart
YTM to Textbox
YUM Disablerepos
systemd PID1
uBlock Filters
udev Hide Partitions
No results
2
Git Multi SSH
tengel edited this page 2024-09-05 08:27:27 -05:00
Table of Contents
git multiple accounts same host
git client 2.10.0 or newer required
problem
scenario:
- two (or more) git accounts at the same host
- git@gitlab.com/user1
- git@gitlab.com/user2
- using unique SSH keys with each git account
- host uses SSH key to know which account to use
- using SSH keyring with both keys in it
- keyring presents keys in internal order
git needs to be explicitly configured to use a given SSH key
solution
Test each account to ensure the "welcome!" message reflect the correct user:
$ ssh -i ~/.ssh/id_rsa_user1 -T git@gitlab.com
Welcome to GitLab, @user1!
$ ssh -i ~/.ssh/id_rsa_user2 -T git@gitlab.com
Welcome to GitLab, @user2!
Within a cloned repository, locally configure that repository to use a specific key:
$ git clone git@gitlab.com:user1/foo.git
$ cd foo
$ git config core.sshCommand "ssh -i ~/.ssh/id_rsa_user1 -F /dev/null"
and/or
$ git clone git@gitlab.com:user2/bar.git
$ cd bar
$ git config core.sshCommand "ssh -i ~/.ssh/id_rsa_user2 -F /dev/null"
This adds the setting to the local .git/config file like so:
[core]
sshCommand = ssh -i ~/.ssh/id_user73 -F /dev/null
...
initial clone
If the initial clone requires a specific SSH key before the above is available, it must be exported to the environment first.
GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa_user99 -F /dev/null" \
git clone git@gitlab.com:user99/privatestuff.git
Any option for SSH can be used (ssh -o StrictHostKeyChecking=no ... e.g.) as needed.
Index
- APT WhatProvides
- Apache wpadmin
- Arch Default Kernel
- Arch Kernel Order
- Bash Add fd
- Bash Dump History
- Bash Trim Whitespace
- CPU Stats
- CSS Reset
- DB2 Info
- Debian Upgrade
- Dell OpenManage
- Diff Lines
- Favicon Things
- Find Examples
- Forgejo Syntax Highlight
- Git Combine Repos
- Git Multi SSH
- Git Quickstart
- Git Rewrite User
- Gitea Mirror
- GitLab Anchors
- Glibc IPv4
- GnuPG Things
- IMAP Sync
- IPv4 Default Gateway
- IPv4 Default IP
- KRB5 Empty Keytab
- Kernel Boot Debug
- Kernel Decompress
- LUKS Encrypted Partitions
- Linux Valid Usernames
- Loopback FS
- MP3 Get Tags
- MX Tarpit
- Makefile Template
- Markdown Samples
- Mount OVA
- Mount qcow2
- MySQL Connections
- NFS 10G Tuning
- Netcat Replacements
- PAM Namespace
- Postfix Headers
- Proxmox Doodads
- RPM Info
- Radeon Temperature
- Recover Deleted ext3
- Recursive Unzip
- Roku Info
- SSH RSA Support
- SSL Certgen
- Samba OSX
- Server Notes
- Smem Datamash
- Split Disk
- systemd PID1
- TCP Kill
- Thunderbird LDAP AD
- uBlock Filters
- udev Hide Partitions
- Weechat Quickstart
- YTM to Textbox
- YUM Disablerepos
- SPDX-License-Identifier: CC-BY-SA-4.0
- SPDX-License-Identifier: MIT