Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@gskielian
Created October 14, 2014 16:51
Show Gist options
  • Star 32 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • 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'
@zhuifeng1017
Copy link

thanks, solved my problem

@langelhc
Copy link

ty

@vampyar
Copy link

vampyar commented Jan 31, 2019

Guys maybe you know how user ~/.ssh/config for Linux, because on the mac os all good. i did make all like in this link

@dersar00
Copy link

dersar00 commented Mar 7, 2019

Nice, thanks!

@ifduyue
Copy link

ifduyue commented Apr 28, 2019

Or this: GIT_SSH_COMMAND='ssh -i /Users/UR_USERNAME/.ssh/UR_PRIVATE_KEY' git clone git@DAS_GIT_URL

@citizencosmos
Copy link

this^ +1

@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