Skip to content

setup SSH key for git repo #91

@OleksandrKucherenko

Description

@OleksandrKucherenko

Checks

Motivation

Overview:

  • common situation when we have multiple accounts: company, personal, provided.

Problem:

  • setup which SSH key git repo should use for pushing the changes in easy way

Solution:

  • setup multiple SSH keys
  • re-configure git repo core.sshCommand and git remote so git start to use a correct SSH key for common operations
# different approaches
git config --global core.sshCommand "ssh -i /path/to/key"
git config --local core.sshCommand "ssh -i /path/to/key"
git submodule foreach git config core.sshCommand "ssh -i /path/to/key"
git config core.sshCommand "ssh -o IdentityAgent=none -i $HOME/.ssh/id_rsa_example -F /dev/null" 

# or setup GIT_SSH_COMMAND env variable

References:

Implementation

  1. If lazyssh executed from git repo folder, we should ask user does he/she needs to reconfigure git repo SSH key or not
  2. support keychain (https://github.com/danielrobbins/keychain) for automatic loading of SSH keys (ref: https://www.funtoo.org/Funtoo:Keychain)
sudo apt-get install keychain
❯ keychain --version

 * keychain 2.8.5 ~ http://www.funtoo.org

   Copyright 2002-2006 Gentoo Foundation;
   Copyright 2007 Aron Griffis;
   Copyright 2009-2017 Funtoo Solutions, Inc;
   lockfile() Copyright 2009 Parallels, Inc.

 Keychain is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License version 2 as
 published by the Free Software Foundation.

Are you willing & able to help?

  • I am able to submit a PR!
  • I can help test the feature!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions