Ubuntu 22.04 ssh-agent IDが正しく追加されていませんか?

Ubuntu 22.04 ssh-agent IDが正しく追加されていませんか?

.bashrcスクリプトの最後にssh IDを追加し、ログインするとサーバーが示すように、エージェントはpid 8411として実行され、すべてのIDが追加されます。

以下のコンソールを見ると、私のIDが利用できないことも明らかです。これを使用するには、sshエージェントを起動するコマンドを入力し(今すぐ新しいpid 8531を受け取る)、エージェントにIDを追加するコマンドを入力する必要があります(やはり?)。その後、gitだけがIDを認識します。リポジトリのインポートを許可します。

何が起こったのか、私は何が間違っていましたか?

Last login: Sat Jul  1 11:51:58 2023 from 162.243.190.66
Agent pid 8411
Identity added: /root/.ssh/id_ed25519 ([email protected])
Identity added: /root/.ssh/id_ed25519_api_requests ([email protected])
Identity added: /root/.ssh/id_ed25519_airspace_sweden ([email protected])
Identity added: /root/.ssh/id_ed25519_hwx ([email protected])
root@DR2-sweden-internal-api:~# cd /var/www/html
root@DR2-sweden-internal-api:/var/www/html# ls
aircraft  airspace  airspace-sweden  drones  index.html
root@DR2-sweden-internal-api:/var/www/html# git clone [email protected]:domain/myrepo-api-out-HemsWX.git
Cloning into 'myrepo-api-out-HemsWX'...
ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
root@DR2-sweden-internal-api:/var/www/html# eval "$(ssh-agent -s)"
Agent pid 8531
root@DR2-sweden-internal-api:/var/www/html# ssh-add ~/.ssh/id_ed25519_hwx
Identity added: /root/.ssh/id_ed25519_hwx ([email protected])
root@DR2-sweden-internal-api:/var/www/html# git clone [email protected]:domain/myrepo-api-out-HemsWX.git
Cloning into 'myrepo-api-out-HemsWX'...
remote: Enumerating objects: 91, done.
remote: Counting objects: 100% (91/91), done.
remote: Compressing objects: 100% (65/65), done.
remote: Total 91 (delta 35), reused 79 (delta 23), pack-reused 0
Receiving objects: 100% (91/91), 20.14 KiB | 2.88 MiB/s, done.
Resolving deltas: 100% (35/35), done.

これが私の~/.bashrcの終わりです

#add github deploy keys to agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
ssh-add ~/.ssh/id_ed25519_api_requests
ssh-add ~/.ssh/id_ed25519_airspace_sweden
ssh-add ~/.ssh/id_ed25519_hwx

------- アップデート(Ulrichのコメント) ----------

だから私は4つのIDのうち最初のIDを使用できることがわかりました。 -vは多くのデバッグラインを提供します =)

debug1: Connecting to github.com [140.82.121.3] port 22.
debug1: Connection established.
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa_sk type -1
debug1: identity file /root/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /root/.ssh/id_ed25519 type 3  // <------ one of my 4 identity files
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: identity file /root/.ssh/id_ed25519_sk type -1
debug1: identity file /root/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /root/.ssh/id_xmss type -1
debug1: identity file /root/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.7

または、探しているアイデンティティ文書の種類のみを一覧表示しますか?さらに下がると、次のような結果が出ます。

debug1: Will attempt key: /root/.ssh/id_ed25519 ED25519 SHA256:pHUHZ1LHAiGC0z---------------------- agent
debug1: Will attempt key: [email protected] ED25519 SHA256:6U2cH2OBWTIuVGx---------------------- agent
debug1: Will attempt key: [email protected] ED25519 SHA256:o+a6AiJJzpLFqjV---------------------- agent
debug1: Will attempt key: [email protected] ED25519 SHA256:Yz4Ayq8x/6bqf9D---------------------- agent
debug1: Will attempt key: /root/.ssh/id_rsa 
debug1: Will attempt key: /root/.ssh/id_dsa 
debug1: Will attempt key: /root/.ssh/id_ecdsa 
debug1: Will attempt key: /root/.ssh/id_ecdsa_sk 
debug1: Will attempt key: /root/.ssh/id_ed25519_sk 
debug1: Will attempt key: /root/.ssh/id_xmss 

それではキーを試しているように見えますが、最初のパスにはなぜ1つのパスしかありませんか?パスがなく、自分のメールアドレスだけを持っている人はいますか?

debug1: Will attempt key: /root/.ssh/id_ed25519 ED25519 SHA256:pHUHZ1LHAiGC0z---------------------- agent
debug1: Will attempt key: [email protected] ED25519 SHA256:6U2cH2OBWTIuVGx---------------------- agent
debug1: Will attempt key: [email protected] ED25519 SHA256:o+a6AiJJzpLFqjV---------------------- agent
debug1: Will attempt key: [email protected] ED25519 SHA256:Yz4Ayq8x/6bqf9D---------------------- agent

---------- アップデート(aviroのコメント) ----------

エージェントは実際に PID 165201 として実行されています。ただし、次のようにそのプロキシにIDを手動で追加しても役に立ちません。また、以下のようにプロキシでevalを再実行してからIDを手動で追加することで問題が解決しました。実行中のエージェントが1つしかないことがわかったので、エージェントでevalを実行したときにPIDが新しいPIDに置き換えられました。

root@DR2-sweden-internal-api:/var/www/html/hwx# echo $SSH_AGENT_PID;
165201
root@DR2-sweden-internal-api:/var/www/html/hwx# ps -fp $SSH_AGENT_PID
UID          PID    PPID  C STIME TTY          TIME CMD
root      165201       1  0 08:14 ?        00:00:00 ssh-agent -s
root@DR2-sweden-internal-api:/var/www/html/hwx# ssh-add ~/.ssh/id_ed25519_hwx
Identity added: /root/.ssh/id_ed25519_hwx ([email protected])
root@DR2-sweden-internal-api:/var/www/html/hwx# git fetch
ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
root@DR2-sweden-internal-api:/var/www/html/hwx# 


root@DR2-sweden-internal-api:/var/www/html/hwx# eval "$(ssh-agent -s)"
Agent pid 166484
root@DR2-sweden-internal-api:/var/www/html/hwx# ssh-add ~/.ssh/id_ed25519_hwx
Identity added: /root/.ssh/id_ed25519_hwx ([email protected])
root@DR2-sweden-internal-api:/var/www/html/hwx# git fetch
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 3 (delta 2), reused 3 (delta 2), pack-reused 0
Unpacking objects: 100% (3/3), 721 bytes | 721.00 KiB/s, done.
From github.com:Naviation/dronerequest-api-out-HemsWX
   7bdda64..c620151  master      -> origin/master
 * [new branch]      version_1.2 -> origin/version_1.2
root@DR2-sweden-internal-api:/var/www/html/hwx# 

ベストアンサー1

おすすめ記事