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!
The first question you can ask yourself is can you have the same ssh key for both Github and Gitlab? The answer is yes but it is not advisable. The best answer is that you should set one ssh key for Github and another one for Gitlab.
Also, since github allows multiple ssh keys to be used with same account, you can create a new keypair and add it to your account.
Since git just uses ssh to connect, it will use whichever key ssh would use to connect to the remote host. See the ~/. ssh/config file for details; the host block uses the IdentityFile directive to specify the private key to use. The ssh_config(5) manpage contains full details.
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.
You can add your directory to ~/.bashrc or ~/.bash_profile. Also you can try to change the home directory of the user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With