### 服务器的系统为Rocky Linux 9.4

1. 进入文件夹~/.ssh/,添加私钥到本地。续注意,根据官方文档,添加的加密类型目前只支持RSA。一路回车生成(可以根据需求添加密码)。
```sh
ssh-keygen -t rsa-sha2-256 -C "yourEmail"
```

2. 文件夹中生成了id_rsa,id_rsa.pub两个文件将私钥添加到本地,然后将公钥的内容复制到Azure DevOps平台的SSH公钥设置的页面并添加。

```sh
ssh-add ~/.ssh/id_rsa_azure
```

 

3. 新建config文件,在配置文件中输入内容:

```sh
Host url
HostName url
IdentityFile ~/.ssh/id_rsa
HostkeyAlgorithms +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa
```

 

4. 运行ssh -T #{url} 对应你自己平台的url来测试是否成功。如果出现提示

```sh
ssh_dispatch_run_fatal: Connection to xxx port 22: error in libcrypto
```

说明ssh不支持git平台的加密版本,我就碰到了这个问题,这时候需要输入指令来支持老版本
```sh
update-crypto-policies --set LEGACY
```

5. 再次运行测试命令,当返回
```sh
remote: Shell access is not supported.
shell request failed on channel 0
```

这两行提示时,说明连接成功了! 是的这个看着像报错的是成功,官方文档就是这么写的,我还以为出问题了。