gitlab网站的IP地址不一定是gitlab远程代码仓库的IP地址,如何获取远程代码仓库的真实IP地址和端口?只需在gitlab网站上创建一个测试仓库,然后在“代码”->“使用SSH克隆”界面就能看到远程仓库的真实IP地址和端口号了:

然后在~/.ssh/config文件里,不能使用gitlab网站的域名作为Host配置项的值,例如:
Host gitlab.jhso.cn
HostName 172.16.1.33
User git
Port 2222
IdentityFile ~/.ssh/id_ed25519_jhso
否则你在本地git clone远程代码仓库时,会报错说“fatal:无法访问远程代码仓库”。
应该使用远程代码仓库的真实IP地址作为Host配置项的值,例如:
Host 172.16.1.33
HostName 172.16.1.33
User git
Port 2222
IdentityFile ~/.ssh/id_ed25519_jhso