user1592380
user1592380

Reputation: 36277

How to change location of private key for git push

I'm working with heroku. My local project which is in a git repository is on a flash drive (F:) I need to change the location of my ssh private key which I originally set up on another computer's c drive to f:/ssh where the private key also resides.

 $ git push [email protected]:MYPROJECT.git master
 The authenticity of host 'heroku.com (x.x.x.x)' can't be established.
 RSA key fingerprint is XXXXXXXXXX.
 Are you sure you want to continue connecting (yes/no)? yes
 Warning: Permanently added 'heroku.com,x.x.x.x' (RSA) to the list of known hosts.
 Permission denied (publickey).
 fatal: Could not read from remote repository.     

 Please make sure you have the correct access rights
 and the repository exists.

How can I do this?

edit:

following Shireesh's instructions I created a 'config' file in my F: drive with directory structure:

F:/.ssh:

id_rsa (private ) 
id_rsa (public ) 
config

config looks like:

Host heroku.com
User git
IdentityFile /id_rsa

when I repeat the push I get:

Permission denied (publickey).
fatal: Could not read from remote repository.

 Please make sure you have the correct access rights
and the repository exists.

Upvotes: 1

Views: 394

Answers (1)

Litmus
Litmus

Reputation: 10996

add the following lines to $HOME/.ssh/config

Host heroku.com
   User git
   IdentityFile /path/to/your/ssh/private_key

This should take care of the location of your ssh key.

Upvotes: 2

Related Questions