我已經在我的 GitLab 組態檔設定中設定了我的公共 SSH RSA 密鑰。在我的遠程服務器上,我已經添加了我的 SSH 私鑰:
ssh-add ~/.ssh/id_rsa
事實上,當我在遠程服務器上運行 SSH 連接驗證時,它已通過身份驗證:
user@some-remote-server:/var/www$ ssh -T [email protected]
The authenticity of host 'gitlab.com (xxx.xx.xxx.xx)' can't be established.
ECDSA key fingerprint is SHA256:anmsdaskdnaslkdmaskd.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'gitlab.com,xxx.xx.xxx.xx' (ECDSA) to the list of known hosts.
Enter passphrase for key '/home/user/.ssh/id_rsa':
Welcome to GitLab, @alramdein!
user@some-remote-server:/var/www$
我是存盤庫的所有者。但是當我運行 Git clone 它說fatal: Could not read from remote repository.
user@some-remote-server:/var/www$ sudo git clone [email protected]:repo/repo.git
Cloning into 'repo'...
[email protected]: Permission denied (publickey,keyboard-interactive).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
user@some-remote-server:/var/www$
uj5u.com熱心網友回復:
您正在使用sudo git clone;這意味著您使用的與ssh-agent您的用戶不同。
如果你想檢查,你可以執行
ssh-add -L
和
sudo ssh-add -L
您會看到兩個帳戶中沒有相同的代理。
我不知道您為什么要git clone使用sudo權限,但是您需要使用sudo(為root用戶)啟動代理并將私鑰附加到它。
此外,由于sudo禁用了環境變數,SSH_AUTH_SOCK因此SSH_AGENT_PID每次使用ssh.
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/332842.html
