Skip to content

git dot ssh directory location #2016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
duaneellissd opened this issue Jan 9, 2019 · 4 comments
Closed

git dot ssh directory location #2016

duaneellissd opened this issue Jan 9, 2019 · 4 comments
Labels

Comments

@duaneellissd
Copy link

Problem statement:

Case (1) When my machine is issolated from the corporate network, my home directory is: c:\users\NAME

Case (2) When my machine is connected to the corporate network, my home directory is: j:
which is by company policy and those above me will not change this.

This means my "$HOME/.ssh" and thus KEYS dynamically move every time

If I am attached to the network, and open a BASH prompt... HOME = the J drive.
If I detach from the network (ie: go into a conference room with laptop)
Or if I go home at the end of the day ...

When I open my laptop back up and launch a second BASH shell
I will have two different HOME directories.

And for example if there are things in your path, ie: $HOME/bin - and that HOME directory is gone...
painful things happen (extreme sluggish ness, etc)

I have tried setting "HOME=/c/users/NAME" in the file /etc/profile
and if I later use the command: ls -l $HOME it works

But when I launch SSH-KEYGEN or any other SSH tool,
It seems to ignore the HOME variable and tries to search the wrong place for my ssh dir

it is very frustrating.

Suggestions?

@duaneellissd
Copy link
Author

This is an example of the problem:
https://stackoverflow.com/questions/32232978/change-the-location-of-the-directory-in-a-windows-install-of-git-bash

I've followed that example and it does not work, for example:

dellis@PW5530-DELLIS MINGW64 ~
$ set | grep HOME
HOME=/c/users/dellis
HOMEDRIVE=C:
HOMEPATH='\users\dellis'
HOMESHARE='\\home-dir\usershare'
dellis@PW5530-DELLIS MINGW64 ~
$ cd $HOME
dellis@PW5530-DELLIS MINGW64 ~
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/j//.ssh/id_rsa): 

And that is the problem - sshkeygen decided to use J drive

Bottom line, it appears that although various variables are set
GIT 100% ignores these no matter what I do.

@rimrul
Copy link
Member

rimrul commented Jan 11, 2019

ssh-keygen grabs your homedir from pw->pw_dir where pw is a struct previously returned by getpwuid(). getpwuid() in MSYS2 gets filled from cached data about your user that was obtained from windows in some way. I'd assume that MSYS2 does not expect your Home directory to change during a windows user session and thus doesn't handle situations where it does change while MSYS2-based processes are running as graciously as you might expect.

@duaneellissd
Copy link
Author

duaneellissd commented Jan 12, 2019 via email

@dscho
Copy link
Member

dscho commented Feb 26, 2019

As long as your /etc/nsswitch.conf contains the line

db_home: env windows cygwin desc

(i.e. db_home is configured to look for env first, meaning the environment variable HOME), and as long as your HOME variable is set before Bash starts up (it is not possible to override it in ~/.profile, for example, as the Bash already started at that point, most importantly: the MSYS2 runtime already read and interpreted /etc/nsswitch.conf), you should be able to have HOME set to what you want, not what your administrator wants. You could use the CMD command setx to set the HOME variable in your user-wide environment, persisted across reboots, for example.

@dscho dscho added the question label Feb 26, 2019
@dscho dscho closed this as completed Oct 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants