LoginSignup
28
10

More than 3 years have passed since last update.

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

Posted at

結論

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」まだですか??????

28
10
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
28
10