Ubuntu 22.04 システム git/repo/github/codeup で ssh でコードをダウンロードできない

新しくインストールされた Ubuntu 22.04 システムでは、デフォルトでは git を使用してコードをダウンロードしたり、リポジトリ、codeup、github などの git ベースのさまざまなコマンドやサービスをダウンロードしたりすることはできません。コマンドを実行すると、次のエラー メッセージが表示されます。

Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

また

kex_exchange_identification: Connection closed by remote host
Connection closed by 123.123.123.123 port 22
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

まず、ローカル側とサーバー側の sshkey の設定に問題がないことを確認してください。

調査の結果、openssh (バージョン 8.x) は、セキュリティ上の理由から、デフォルトの暗号化アルゴリズム rsa を SHA-1 に置き換えました。構成ファイルを通じてデフォルトの暗号化アルゴリズムを変更し、引き続き rsa アルゴリズムを使用できます。

このマシンにインストールされている openssh-server のバージョンを確認します。バージョン 8.9 です。

$ apt search openssh-server
Sorting... Done
Full Text Search... Done
openssh-server/jammy-updates,now 1:8.9p1-3ubuntu0.1 amd64 [installed]

デフォルトの暗号化アルゴリズムを変更するには、次のオプションを構成ファイルに追加できます。

PubkeyAcceptedKeyTypes +ssh-rsa

ローカル構成ファイル (~/.ssh/config) を変更します。

$ cat .ssh/config 
Host your.git.domain
HostName your.git.domain
# PreferredAuthentications publickey
PubkeyAcceptedKeyTypes +ssh-rsa
IdentityFile ~/.ssh/id_rsa

変更後のテスト:
gitサーバーに正常にアクセスできます。

$ ssh -p <git_port> [email protected]
  ****    Welcome to Gerrit Code Review    ****
  Hi git_user_name, you have successfully connected over SSH.
Connection to gerrit.qisi.ltd closed.

おすすめ

転載: blog.csdn.net/yinminsumeng/article/details/130481253