error: The requested URL returned error: 401 Unauthorized while accessing http://git.xxxxx.com/phpGroup/xx.git/info/refs
我通过dev用户登录到公司的测试环境机器上面,然后执行了下面的命令
[dev@iZ2385638icZ www]$ sudo git clone http://git.xxxxx.com/phpGroup/xx.git
sudo命令用来以其他身份来执行命令,预设的身份为root。也就是执行sudo git clone的用户实际上是root。也就是说,需要把root用户的ssh公钥加进去,而不是dev用户的。
我的公司是使用gitlab来做git服务器的,对于测试环境或者线上的机器,应该把ssh公钥加到deployKey里面,再启用一下即可。
但是,加进去了还是不行,因为不能使用http协议。换成下面的ssh协议就ok了
sudo git clone git@git.xxxxx.com:phpGroup/xx.git
sudo命令用来以其他身份来执行命令,预设的身份为root。
ssh公钥基于git协议