1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

GCE(Google Compute Engine)でgit clone時に詰まった話

Last updated at Posted at 2022-07-07

件名の通り。
インスタンスを作ってログインし、sshでgit cloneしようとしたら詰まった。
出たエラーは

git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

原因は最初にパーミッションエラーが出た際、それを回避しようとしてsudoを付けたことだった。
今まで
「sudoをつけてコマンドを叩く = root権限でコマンドを実行」
だと思っていたのだが
実際は
「sudoをつけてコマンドを叩く = rootユーザーでコマンドを実行」
だったらしい。
なので現ユーザー配下に作成した鍵(id_rsa)ではなくrootユーザーの鍵を見に行って失敗していた模様
解決策としては

  1. rootユーザーの.ssh配下に鍵を配置する
  2. 現ユーザーのユーザーグループcloneしたいディレクトリのパーミッションを変更してsudoなしでコマンドを叩く

2の場合は

su - 
sudo usermod -a -G root ユーザー名
cd ..
chmod 775 ディレクトリ名

でOK。
1が無難な気がする。

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?