望ましい設定
.ssh : 700
.ssh/id_rsa : 600
james$ chown 700 .ssh
james$ chown 600 .ssh/id_rsa
james$ ls -al .ssh
drwx------ 6 james staff 204 5 12 17:50 .
-rw-r--r-- 1 james staff 278 5 12 17:44 config
-rw------- 1 james staff 1676 5 12 17:46 id_rsa
-rw-r--r-- 1 james staff 448 5 12 17:48 known_hosts
環境
Mac OSX Yosemite
いきさつ
Windowsで使っていたキーとconfigをコピーして使おうとしたらエラーが出て、git clone
が失敗。。。
$ git clone ssh://git@example.com/var/git/hello/helloworld.git
Cloning into 'helloworld'...
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/Users/james/.ssh/id_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /Users/james/.ssh/id_rsa
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
鍵ファイルのパーミッションが緩すぎるらしいです。
しっかりしてますね。
ソース:Permissions on private key in .ssh folder?
もっとちゃんとしたソースが欲しかったけど面倒臭かった。すみません。