LoginSignup
42
34

More than 5 years have passed since last update.

msys2での$HOMEとOpenSSHでのホームディレクトリの違い

Posted at

はじめに

自分の記事であるMSYS2でWindows上にコマンドライン環境を作る - QiitaにあるようにC:\Users\username\UnixHome$HOMEに設定していたがgit pullでエラーが出た

$ git pull
Could not create directory '/home/username/.ssh'.
The authenticity of host 'github.com (192.30.252.131)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/home/username/.ssh/known_hosts).
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

エラーへの対応

MSYS2 / Tickets / #111 MSYS2 ssh not finding ssh config or IdentityFile (incorrect tilde expansion when HOME env set)というチケットがMSYS2に上がっている。

http://sourceforge.net/p/msys2/tickets/111/#5fab
- /etc/fstabを書く
- Windowsネイティブのシンボリックリンクを張る
2つの解決法のどちらかを選択すればよい。
私は/etc/fstabを選択しました。

/etc/fstabへの追加

http://sourceforge.net/p/msys2/tickets/111/#5fab 通りにします。
C:\Users\username\UnixHomeをホームディレクトリとして扱いたいので

C:/Users/username/UnixHome /home/username

という記述を/etc/fstabに追加します。
あとはMSYS2のシェルを立ち上げ直せばOK

まとめ

チケット をちゃんと眺めてもらえばいいのですが、OpenSSHが$HOMEを読まないことがこの問題のようです。
通常はOpenSSHは/etc/passwdを読んでいるところを、Alex83さんが対応して/etc/fstabを書けばよくなったためこの対応をするだけでよくなりました。

Msys2を使うさいはご注意を。
より良いWindowsでのターミナル生活を!

42
34
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
42
34