0

WSLではマウントしたドライブ上のファイルにchmod効かないから気をつけろって話

結論

wsl上の.sshにでも鍵をコピーしてからchmodで権限を変更して使え

wsl上でsshしたくなった

windowsも最近よく頑張っているのでpowershell上からsshするのも悪くないのだが,細かいコマンドについてはやっぱりlinuxが使いたくなる.
wslつかってssh(又はscp)しようとしたところunprotectedで起こられた

> ssh -i /mnt/c/Users/pengu/.ssh/hoge.pem user@host
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0777 for '.ssh/hoge.pem' are too open.
It is required that your private key files are NOT accessible by others.

OK, OK.権限関連で怒ってるのねわかるよ分かる

> ls -la .ssh/
-rwxrwxrwx 1 penguin penguin 1696 Feb  8  2019 hoge.pem

そりゃ怒られますね
よっと

> chmod 600 .ssh/hoge.prm
> ls -la .ssh
-rwxrwxrwx 1 penguin penguin 1696 Feb  8  2019 hoge.pem

なんで?(この後安易にsudoも試した)

どうやらwsl上のchmodはマウントしたものに効かないらしい

https://github.com/Microsoft/WSL/issues/3181
そもそもwindowsは権限をOS上で管理しているからファイル自体での制限には無頓着なんですねわかる

解決策

おとなしくwsl上にコピーして権限を変更して使う

> cp .ssh/hoge.pem ~/.ssh/
> chmod 600 ~/.ssh/hoge.pem
> ssh -i ~/.ssh/hoge.pem user@hoge

P.S MicroSoftさん「windows terminal」まだですか??????

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away