0
1

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.

Bitbucketからcloneできない問題【備忘録】

Last updated at Posted at 2023-04-04

Bitbucketからcloneできない問題【備忘録】

背景

  • bitbucketからリポジトリをクローンしようとしたら下記エラーが発生した
git@bitbucket.org: Permission denied (publickey). fatal: Could not read from remote repository.

結論

  • SSH認証エージェントに秘密鍵を登録していなかった。
  • 鍵を作成しBitbucketに登録するだけでよいと思っていたのが原因であった。

行ったこと

解決手順

BitbucketにSSH接続を試みる

ssh -vvv git@bitbucket.org
  • 下記エラーからルートユーザーの直下にid_rsaがないことがわかる。
  • 秘密鍵は/home/ユーザー/.shhに作成しているためない。
debug1: Trying private key: /root/.ssh/id_rsa
debug3: no such identity: /root/.ssh/id_rsa: No such file or directory

SSH認証エージェントに秘密鍵を登録する

  • 上記状態を解決するためにSSH認証エージェントに秘密鍵を登録していると、SSH認証時に登録している秘密鍵を使用してくれるとのこと。

  • 既に登録されている鍵を確認

ssh-add -l
  • 認証エージェントの接続を開くことができないというエラー
Could not open a connection to your authentication agent.
  • 認証エージェントに接続するにはまず認証エージェントを起動する必要があるとのこと。
ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-XXXXXXXXXX/agent.00000; export SSH_AUTH_SOCK;
SSH_AGENT_PID=00000; export SSH_AGENT_PID;
echo Agent pid 25209;
  • するといかにも起動した感じがするのだが、改めてリストを表示しようとすると...
Could not open a connection to your authentication agent.
  • 実はWindowsだとエージェントを起動するにはevalでないといけないらしい。
$ eval `ssh-agent`

参考 : https://qiita.com/sshojiro/items/60982f06c1a0ba88c160

  • ようやく起動できたので秘密鍵のパスを指定して追加
ssh-add /home/ユーザー名/.ssh/id_rsa
  • 確認
ssh-add -l
3072 SHA256:Sqb+XXXXXXXXXXXXXXXXXXX root@XXXXX (RSA)
0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?