Miles
Miles

Reputation: 1888

Portable Git and GitHub: SSH Keys

I downloaded the portable version of Git for Win32, the one that comes in a self-extracting package. I wanted to be able to push commits from anywhere (my flashdrive), but I have no idea how to use a public key that isn't in users/USERNAME/.ssh. How can I configure Git to automatically use keys in another directory?

(I can generate keys in other directories, but Git automatically sends the keys in c:/users/me/.ssh)

NOTE: I am using Win32! Not Linux or OSX!

Upvotes: 6

Views: 10561

Answers (3)

1234ru
1234ru

Reputation: 842

Changing core.sshCommand made it for me.

The idea behind this is to explicitly set path to the key file via -i option of the ssh command:

git config --system core.sshCommand  "ssh -i /d/keys/key.openssh"

(I also added my user name - -l username, because it's the same for me on all servers I connect to, and I didn't bother to specify it on git remote addresses.)

Keep in mind that paths should be given Unix-way, the one above is actually D:\keys\key.openssh.

Note: portable Git stores it's system-wide settings in mingw64/etc/gitconfig file.

Upvotes: 0

VonC
VonC

Reputation: 1326686

msysgit will actually use public/private keys in %HOME%/.ssh.

By default, msysgit defines HOME to C:\users\USERNAME, but nothing prevents you to define HOME to any path you want.

Simply define a user environment variable 'HOME', and then all your shell/DOS sessions will inherit that new value.

Upvotes: 6

Fatih Acet
Fatih Acet

Reputation: 29549

You can add your directory to ~/.bashrc or ~/.bash_profile. Also you can try to change the home directory of the user.

Upvotes: 1

Related Questions