Skip to content

Instantly share code, notes, and snippets.

@gskielian
Created October 14, 2014 16:51
Show Gist options
  • Save gskielian/b3f165b9a25c79f82105 to your computer and use it in GitHub Desktop.
Save gskielian/b3f165b9a25c79f82105 to your computer and use it in GitHub Desktop.
Specifying SSH Key within Git Clone
#how to specify an ssh key to use when cloning a repo in Mac
ssh-agent bash -c 'ssh-add /Users/UR_USERNAME/.ssh/UR_PRIVATE_KEY; git clone git@DAS_GIT_URL'
@vikas027
Copy link

GIT_SSH_COMMAND= works great. The only thing to be mindful is that you need git version > 2.3.0

On CentOS 7, you can upgrade git as below

# yum remove git*
# yum -y install https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.7-1.x86_64.rpm
# yum -y install git

@xucian
Copy link

xucian commented Nov 4, 2021

GIT_SSH_COMMAND= works great. The only thing to be mindful is that you need git version > 2.3.0

On CentOS 7, you can upgrade git as below

# yum remove git*
# yum -y install https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.7-1.x86_64.rpm
# yum -y install git

Thanks! I was struggling with GIT_SSH_COMMAND on git 2.24.3 and you saved me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment