Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 487
Miles Avatar asked Dec 10 '11 23:12

Miles


People also ask

Can I use the same SSH key for GitHub and Gitlab?

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.

Can you use the same SSH key on multiple computers GitHub?

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.

What SSH key is git using?

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.


2 Answers

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.

like image 147
VonC Avatar answered Sep 25 '22 15:09

VonC


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

like image 24
Fatih Acet Avatar answered Sep 24 '22 15:09

Fatih Acet