英文:
Using local private key to push a repository to a git server (github) on a remote server
问题
I have a private key that has access to my GitHub (Also I use it to connect a bunch of servers through SSH) and I use it to push/pull on my GitHub.
我有一把可以访问我的GitHub的私钥(同时也用它连接多台服务器通过SSH),我用它来推送/拉取GitHub上的代码。
I have to develop code on a server with the SSH Remote option of VSCode, and it's nice to develop and run codes on the server but there is a problem. When I finished the code, I could not push my commits to GitHub because my private key was not on that server.
我必须在VSCode的SSH远程选项下在服务器上开发代码,这样在服务器上开发和运行代码很好,但出现了问题。当我完成代码后,无法推送我的提交到GitHub,因为我的私钥不在那台服务器上。
I develop on different servers, I do not want to share my local private key and put it on any other server.
我在不同的服务器上开发,我不想共享我的本地私钥并放在其他服务器上。
I do not know what should I do. should I create a private key for each server? then give assign it to the corresponding repository on GitHub?
我不知道该怎么办。我是否应该为每台服务器创建一个私钥?然后将其分配给对应的GitHub存储库?
OR
或者
Can I just use my local private key (that I am using to connect the remote servers & has access to my GitHub) just for push? it would be great if we had this option
我是否可以只使用我的本地私钥(用于连接远程服务器并具有访问GitHub权限)来进行推送?如果有这个选项将会很棒。
Is there any option like this? "using your local ssh key on a remote shell without copying it on the remote server"?
是否有这样的选项?“在远程shell上使用本地SSH密钥,而无需将其复制到远程服务器上”?
When I search about this, I just get how to set up ssh on a remote server or how to set up an ssh key for GitHub. I tried searching keywords like "tunneling private key" or... It did not help.
当我搜索这个问题时,我只找到了如何在远程服务器上设置SSH或如何为GitHub设置SSH密钥的信息。我尝试搜索关键词如“隧道私钥”,但没有找到有用的信息。
英文:
I have a private key that has access to my GitHub (Also I use it to connect a bunch of servers through SSH) and I use it to push/pull on my GitHub.
I have to develop code on a server with the SSH Remote option of VSCode, and it's nice to develop and run codes on the server but there is a problem.
When I finished the code, I could not push my commits to GitHub because my private key was not on that server.
I develop on different servers, I do not want to share my local private key and put it on any other server.
I do not know what should I do. should I create a private key for each server?
then give assign it to the corresponding repository on GitHub?
OR
Can I just use my local private key (that I am using to connect the remote servers & has access to my GitHub) just for push? it would be great if we had this option
Is there any option like this? "using your local ssh key on a remote shell without copying it on the remote server"?
When I search about this, I just get how to set up ssh on a remote server or how to set up an ssh key for GitHub. I tried searching keywords like "tunneling private key" or... It did not help.
答案1
得分: 2
你正在寻找SSH代理转发。启用转发后,您在本地ssh代理中加载的任何身份也可以从远程服务器使用。
英文:
You're looking for SSH Agent Forwarding. With forwarding enabled, any identities that you have loaded into your local ssh-agent will also be usable from remote servers.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论