https://github.com/chsxf/git-ssh-bash-scripts
A collection of scripts to facilitate git repositories management with multiple SSH keys
https://github.com/chsxf/git-ssh-bash-scripts
git shell-scripts ssh
Last synced: 2 months ago
JSON representation
A collection of scripts to facilitate git repositories management with multiple SSH keys
- Host: GitHub
- URL: https://github.com/chsxf/git-ssh-bash-scripts
- Owner: chsxf
- License: mit
- Created: 2024-06-28T21:32:17.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-28T22:11:15.000Z (about 2 years ago)
- Last Synced: 2025-01-19T21:47:31.228Z (over 1 year ago)
- Topics: git, shell-scripts, ssh
- Language: Shell
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# About This Repository
Have you ever tried to use multiple repositories from the same vendor (GitHub, BitBucket, GitLab, ...) but with different SSH keys? _Well, that's not easy._
Indeed, your SSH agent will probably only support automatically one key per domain. However, you can assign specific keys to each repository with adequate git configuration settings ([`core.sshCommand`](https://git-scm.com/docs/git-config#Documentation/git-config.txt-coresshCommand)).
This repository contains a collection of shell scripts to facilitate git repositories management with multiple SSH keys.
# Scripts
Most scripts will guide you through the process.
## Add All SSH Keys to the Agent
In case your agent loses track of some of your keys, you can all them all at once with this script. Keys must be stored in `~/.ssh` (which is the default SSH folder).
Usage:
```shell
ssh-add-all-keys.sh
```
## Cloning a Repository
Clones a repository and assigns a SSH key to it. The specified repository will be cloned in a sub-folder.
Usage:
```shell
gcssh
```
## Adding a New Remote to an Existing Repsitory
Adds a new remote to an existing repository and assign a specific SSH key to it. You must execute this script from the folder of the repository.
Useful if the git repository has been initialized locally and not cloned.
Usage:
```shell
garssh
```
## Adding a Submodule to an Existing Repository
Adds a submodule to an existing repository and assign a specific SSH to it. You must execute this script for the folder of the repository.
Usage:
```shell
gasmssh
```
## Initializing Submodules for an Existing Repository
In some cases, submodules must be initialized with the SSH key of the repository. This script is designed for that. You must execute this script for the folder of the repository.
Usage:
```shell
gismssh
```
## Assign a SSH key to an Existing Repository
This script sets the SSH key to use for a repository. You must execute this script for the folder of the repository.
Usage:
```shell
gsetsshcfg
```