[英]How to use local Github ssh key when issuing remote git commands on another machine via ssh
[英]ssh key issue connecting to github via remote machine
我在遠程訪問的機器上使用git(github)有一些問題。 我通過ssh從家里登錄到我的工作計算機
me@home$ ssh me@work
之后,我嘗試通過家庭例如對我的工作計算機上的github進行拉取或推入請求
me@workViaHome$ git pull origin branch
之后我收到錯誤:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我嘗試使用以下方法從工作計算機加載ssh密鑰:
me@workViaHome$ eval "$(ssh-agent -s)"
me@workViaHome$ ssh-add ~/.ssh/id_rsa
但仍然沒有運氣。 當我身在工作計算機上時,我可以毫無問題地向github發出請求; 所以由於我的ssh會話,我的ssh-key的狀態似乎有問題。
謝謝你的幫助!
如果未在配置中另行指定,或者ssh-agent
未提供其他任何密鑰,則SSH使用默認密鑰。
如果您在gnome-keyring
添加了非標准位置gnome-keyring
,則可能會注意到此現象,因為gnome-keying
僅針對圖形會話開始,而不適用於ssh
會話。
當然,您可以通過在工作計算機上的~/.ssh/config
正確配置此密鑰來解決此問題。 只需添加
Host github.com
IdentityFile ~/.ssh/path_to_key
IdentitiesOnly yes
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.