LoginSignup
6
9

More than 5 years have passed since last update.

ssh設定メモ:鍵ファイルのパーミッション

Posted at

望ましい設定

.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?

もっとちゃんとしたソースが欲しかったけど面倒臭かった。すみません。

6
9
0

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
6
9