STR:
1) Remove/rename old C:\msys64 directory.
2) Set the env variable HOME to "C:\Users\Ed" (replace for your username).
3) Ensure there is no .profile in "C:\Users\Ed" that could interfere.
4) Install msys2-x86_64-20141113.exe
5) Run msys2_shell.bat
6) $ pacman -Sy
7) $ pacman --needed -S bash pacman msys2-runtime
8) Exit the shell.
6) Run msys2_shell.bat
7) $ ssh people.mozilla.org -v
OpenSSH_6.7p1, OpenSSL 1.0.1j 15 Oct 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to people.mozilla.org [63.245.214.133] port 22.
debug1: Connection established.
Could not create directory '/home/Ed/.ssh'.
...
8) $ ssh people.mozilla.org -v -F ~/.ssh/config
OpenSSH_6.7p1, OpenSSL 1.0.1j 15 Oct 2014
debug1: Reading configuration data /c/Users/Ed/.ssh/config
debug1: /c/Users/Ed/.ssh/config line 64: Applying options for *
debug1: Connecting to people.mozilla.org [63.245.214.133] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/Ed/.ssh/foo_rsa type -1
...
9) $ ls -al ~/.ssh/config
-rw-r--r-- 1 Ed None 2072 Oct 29 12:11 /c/Users/Ed/.ssh/config
Expected result:
ssh successfully loads the config from ~/.ssh/config (which has an absolute path of /c/Users/Ed/.ssh/config).
When passed the config file using -F, ssh successfully finds the ssh key, which is referenced in the config as "~/.ssh/foo_rsa" (which has absolute path /c/Users/Ed/.ssh/foo_rsa).
Actual result:
ssh doesn't find the config at ~/.ssh/config, and can be seen trying to create a directory at "/home/Ed/.ssh".
When passed the config file using -F, ssh incorrectly expands "~/.ssh/foo_rsa" to "/home/Ed/.ssh/foo_rsa" rather than "/c/Users/Ed/.ssh/foo_rsa".
tl;dr: For some reason MSYS2's ssh expansion of "~" doesn't take into account HOME, but the |ls -al| in step 9 finds it with no problems.
Sorry my copy/pasting and numbering leaves a lot to be desired.
The correct steps prior to the ssh commands themselves, are:
1) Uninstall previous copy of MSYS2 and delete C:\msys64 directory if present.
2) Set the env variable HOME to "C:\Users\Ed" (replace for your username).
3) Ensure there is no .profile in "C:\Users\Ed" that could interfere.
4) Install msys2-x86_64-20141113.exe
5) Run msys2_shell.bat
6) $ pacman -Sy
7) $ pacman --needed -S bash pacman msys2-runtime
8) Exit the shell.
9) Run msys2_shell.bat
10) $ pacman -Su
11) $ pacman -S openssh
...
Adding the following to /etc/fstab resolves the above issue:
However:
1. This should be set up as part of msys2 install (/as an additional task in /etc/post-install/)
2. Adding that mount means that the "wrong" path is output ("/home/Ed" instead of the expected "/c/Users/Ed") for:
...and also performing a |cd /c/Users/Ed| shows the prompt as "Ed@machine /c/Users/Ed" instead of "Ed@ed-laptop ~".
Last edit: Ed 2014-11-18
I can confirm this bugging bug.
From the OpenSSH README:
So if understood correctly creating a file ~/etc/passwd with pw_dir=~/.ssh resolves the issue?
Le 02/12/2014 12:14, Alexx83 a écrit :
Related
Tickets: #111
No. This is about
/etc/passwd
file, not ~/etc/passwd
Ok. So you say that setting the msys2folder/etc/passwd file as indicated solves the problem?
Should msys2 then be setup like this by default? (In case the user don't have write access to that folder.)
We two-tree weeks ago migrate from /etc/passwd to new Cygwin account mapping scheme. So NO we will never back to /etc/passwd. If you need it you need create it yourself.
Or try add to /etc/fstab line:
Hi Ed,
Previously, I was using
/etc/passwd
to change my user's home. Now that file/etc/passwd
is not used anymore, I moved to mounting my Windows user home directory (C:/Users/movachon
) to/home/movachon
.Here the steps:
Add a new line in
/etc/fstab
to mountC:/Users/movachon/
to/home/movachon
. Here my own line:C:/Users/movachon /home/movachon ntfs noacl,binary,posix=1,user 0 0
I used
noacl
because whenacl
was used (which is the default if I remember correctly, I had some problems).Create directory
/home/movachon
in msys2 root filesystem:mkdir -p /home/movachon
.Mount the new mount point using
mount -a
Check that it is mounted correctly using
mount
. You should see your Windows user home directory in the list, something like:C:/Users/movachon on /home/movachon type ntfs (binary,noacl,user)
.Change your HOME env variable to point to
/home/movachon
.This worked for me. Obviously, change
movachon
with your username which I think isEd
.MSYS mount by default with "noacl".
You can mount /home for all users to Windows home folder in /etc/fstab:
And you don't need HOME environment variable anymore
Thank you Alex, works perfectly now.
Interesting, thanks for the clarifications :)
I think there's still a missing initial install step or at the least documentation piece here - this "just works" with MSYS1, but not MSYS2 - but I'll open a new ticket for those if you prefer...
What do you mean? MSYS2 is not MSYS1 fork, it new implementation of MSYS on top of recent Cygwin.
I suppose he means that it should not be the user's duty to mount these
directories to make ssh work, but it should do so out of the box.
By default used /home directory inside MSYS installation folder. I will not change it to use Windows folder by default sorry.
Ok, so a good workaround may be symlinking your dotfile folders into the msys home dir ?
If you need have home directory in Windows users directory you have 2 ways:
Add to /etc/fstab:
C:\Users /home
and remove home directory from MSYS folder
Create native Windows symlink for home directory. Cygwin symlinks not supported in MSYS2.
Ok.That the home dir is not that of the user but that in the msys2 folder likely will continue to confuse a lot of users, so that you should you stress it somewhere on your homepage.
I'm away for work at the moment, so will have to wait until I'm back to dig into the suggested workaround more - but my main point was that the current behaviour involves manual steps (which could potentially be avoided if the MSYS2 installer set things up either by having an advanced mode with prompts, or if it just check the env HOME value and adjusted fstab accordingly). Even if you didn't want to do that, this issue could still be avoided by some wiki/docs changes (ultimately I only filed this bug report because the behaviour was non-obvious and non-documented on the MSYS2 side).
But somehow the home dir is also all over the place because bash_profile is
loaded from the Windows home Directory. That's why one doesn't expect .ssh
to have to linger in the Msys2 folder.
There are changes in
https://cygwin.com/preliminary-ug/ntsec.html
about home directory and nsswitch.conf
Read it.
Sorry to dig up and old issue but I just burned like 3 hours trying to hunt down why my HOME environment variable was not working with SSH.
I utilize msys2 with Git on Windows (the msysgit project is using this new approach). I keep my cygwin home directory in dropbox on some distant directory on my drive, like so:
I map HOME to this in my Windows System Environment Variables:
When I use git to fetch a clone over SSH or use SSH directly, I expect the following .ssh directory to be utilized:
However this is not the case, it is looking for '/home/Robert/.ssh' which does not exist on my system.
It seems there is a special case for SSH but everything else properly uses $HOME. I wish it were more obvious that the user has to manually go into C:\msys32\home and run this on Windows 7:
Could you automate this in the installer? I see two practical approaches:
Either way I agree this should be automated. If I use this tooling at work, I am going to have 20 very confused and upset co-workers because none of them are linux developers, they only use msys as a "means to an end" for git tooling.