Skip to content

chsxf/git-ssh-bash-scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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).

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:

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:

gcssh <git_ssh_uri>

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:

garssh <git_remote_ssh_uri>

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:

gasmssh <git_submodule_ssh_uri>

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:

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:

gsetsshcfg

About

A collection of scripts to facilitate git repositories management with multiple SSH keys

Topics

Resources

License

Stars

Watchers

Forks

Languages