Pearson
Pearson

Reputation: 107

rsa key in different folder than .ssh

I am trying to clone a git repo on a university server but I have only r-x access to the .ssh folder. Hence, I can't generate rsa keys in the .ssh folder, which I need for accessing the server where the git repo is.
I now generated the keys in a git_keys directory in my home dir.

Is it possible to tell git clone to take the rsa keys from a different directory than ~/.ssh?

Upvotes: 5

Views: 11631

Answers (1)

VonC
VonC

Reputation: 1326706

Checking man ssh, you can at least specify the path of the private key with -i

ssh -i /path/to/private_key

The other approach is to use a config file (by default in ~/.ssh/config), but you can, with the -F option, specify a different config file.

You can, however, avoid the config file entirely, with "How to specify an SSH key with git, without using a config file"

ssh-agent bash -c 'ssh-add /path/to/private_key; git pull'

Upvotes: 7

Related Questions