我ssh key為我的Gitlab帳戶配置并想要git clone我的倉庫,但克隆僅在Powershell以管理員身份運行時有效。
以下命令在兩種情況下的作業方式相同(有管理員權限和沒有管理員權限):
ssh -T git@my.gitlab.host.com
輸出是:Welcome to GitLab, @username!
我如何才能在不以管理員身份git clone運行的情況下作業?Powershell
更新 1:
whoami兩種情況的輸出也相同(有管理員權限和沒有管理員權限)
更新 2:
git clone命令錯誤:
[email protected]:權限被拒絕(公鑰)。致命:無法從遠程存盤庫中讀取。
請確保您具有正確的訪問權限并且存盤庫存在。
更新 3:
git push命令失敗并出現同樣的錯誤。訪問ssh key位于的私人問題~/.ssh/id_rsa?
更新 4:我按照VonC的建議為( )
設定了默認ssh命令,但是使用此命令:(設定對我不起作用)命令的
前 19 行輸出(無管理員):gitssh -Tv
git config --global core.sshCommand "ssh -Tv"GIT_SSH_COMMANDgit pull
OpenSSH_8.8p1, OpenSSL 1.1.1m 14 Dec 2021
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to my.gitlab.host.com [my.gitlab.host.ip] port 22.
debug1: Connection established.
debug1: identity file /t/.ssh/id_rsa type -1
debug1: identity file /t/.ssh/id_rsa-cert type -1
debug1: identity file /t/.ssh/id_dsa type -1
debug1: identity file /t/.ssh/id_dsa-cert type -1
debug1: identity file /t/.ssh/id_ecdsa type -1
debug1: identity file /t/.ssh/id_ecdsa-cert type -1
debug1: identity file /t/.ssh/id_ecdsa_sk type -1
debug1: identity file /t/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /t/.ssh/id_ed25519 type -1
debug1: identity file /t/.ssh/id_ed25519-cert type -1
debug1: identity file /t/.ssh/id_ed25519_sk type -1
debug1: identity file /t/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /t/.ssh/id_xmss type -1
debug1: identity file /t/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.8
git pull命令(管理員)的前 9 行輸出:
OpenSSH_8.8p1, OpenSSL 1.1.1m 14 Dec 2021
debug1: Reading configuration data /c/Users/my_user/.ssh/config
debug1: /c/Users/my_user/.ssh/config line 1: Applying options for my.gitlab.host.com
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to my.gitlab.host.com [my.gitlab.host.ip] port 22.
debug1: Connection established.
debug1: identity file C:/Users/my_user/.ssh/id_rsa type 0
debug1: identity file C:/Users/my_user/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.8
所以看起來在無管理員模式下它甚至不會嘗試在正確的位置找到密鑰/配置。對這種行為有任何想法嗎?
uj5u.com熱心網友回復:
在這兩種情況下(管理員或無管理員),首先設定:
set "GIT_SSH_COMMAND=ssh -Tv"
這樣,您將看到訪問了哪個密鑰(從哪個檔案夾),并且可以比較兩個會話。
看起來在無管理員模式下,它甚至不會嘗試在正確的位置找到密鑰/配置。
它看起來像,在無管理員模式下,有一個環境變數HOME設定為T:\or /t。
輸入set HOMECMD 進行確認。
將該變數設定為%USERPROFILE%意味著使用正確的路徑。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/493155.html
下一篇:洗掉舊的提交保留更改
