如何使用本機 ssh 金鑰檢查遠端電腦上的 git 來源?

如何使用本機 ssh 金鑰檢查遠端電腦上的 git 來源?

機器 alice 想要將程式碼部署到機器 bob - 這是雲端某處新啟動的伺服器。程式碼位於私人倉庫 alice 有 ssh 金鑰。

基本上愛麗絲想要ssh bob "git clone git@repo",但以某種方式轉發密鑰。

需要做什麼才能讓這項工作發揮作用?

答案1

這就是所謂的ssh-代理轉發並且有-A它的開關ssh。如果您熟悉 ssh-agent,只需執行ssh -A bob "git clone git@repo"即可,它應該可以完成工作(-tt如果不起作用,可以嘗試新增選項)。

如果您沒有聽說過ssh-agent,您可以繼續閱讀:

eval `ssh-agent`  ## start ssh-agent
ssh-add your.key  ## add your key to agent, possibly unlocking if encrypted
ssh -A bob        ## gets you to remote server with rather safe access to your local key

相關內容