Scott Robinson Technical Lead

Clone a git repo using a specific SSH private key

If you wish to clone a repo using a set private key, you can use the following syntax to do just that and it won’t add the private key to your usual SSH settings:

ssh-agent bash -c 'ssh-add private.key; git clone git@server.com:user/repo.git'

Found this useful? Everything here is free and stays that way. If it saved you an afternoon, you can buy me a coffee.