Memo

メモ > サーバ > 各論: Git > 複数サーバにCLONE

■複数サーバにCLONE
「ssh-keygen -t rsa」で鍵を作成したサーバを複製した場合、各サーバが同じ鍵を持つのでデプロイに問題はない 複数台で構築済みのサーバの場合、各サーバで鍵を作成すると鍵の内容が異なるのですべての鍵をGitHubなどに登録する必要がある もしくは作成済みの id_rsa と id_rsa.pub を各サーバに複製すれば、同じ鍵を持つことになるのでデプロイに問題はない ただし複製の際に権限に注意しないと、CLONEの際に以下の警告が表示される
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0664 for '/var/lib/nginx/.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. Load key "/var/lib/nginx/.ssh/id_rsa": bad permissions Permission denied (publickey). fatal: Could not read from remote repository.
権限 0664 は危険だと警告されている この場合、鍵の複製元サーバに合わせて、以下のように調整するとCLONEできるようになる
$ cd /var/lib/nginx/.ssh $ ll 合計 12 -rw-rw-r-- 1 nginx nginx 1675 4月 26 10:55 id_rsa -rw-rw-r-- 1 nginx nginx 434 4月 26 10:55 id_rsa.pub -rw-r--r-- 1 nginx nginx 409 4月 26 11:43 known_hosts $ chmod 0600 id_rsa $ chmod 0644 id_rsa.pub $ ll 合計 12 -rw------- 1 nginx nginx 1675 4月 26 10:55 id_rsa -rw-r--r-- 1 nginx nginx 434 4月 26 10:55 id_rsa.pub -rw-r--r-- 1 nginx nginx 409 4月 26 11:43 known_hosts

Advertisement