克隆到 '***'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
在服务器使用git clone项目到服务器时,出现上述错误。
原因,服务器的公钥没有加入项目。
解决方法:
使用:ssh-keygen -t rsa 生成秘钥。
但是我在执行该指令时出现权限错误如下:
Generating public/private rsa key pair.
Enter file in which to save the key (/data/***/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
open /data/***/.ssh/id_rsa failed: Permission denied.
Saving the key failed: /data/***/.ssh/id_rsa.
使用 ls -alhf 发现是因为***账户下没有访问.ssh文件的权限
故 (***为账户名称)
sudo chown ***:*** -R .ssh
更改.ssh文件夹访问权限,重复ssh-keygen -t rsa 即可。
然后把公钥保存到gitlab
保存即可。